python类__version__()的实例源码

PsiMarginal.py 文件源码 项目:Psi-staircase 作者: NNiehof 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def meta_data(self):
        import time
        import sys
        metadata = {}
        date = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(time.time()))
        metadata['date'] = date
        metadata['Version'] = self.version
        metadata['Python Version'] = sys.version
        metadata['Numpy Version'] = np.__version__
        metadata['Scipy Version '] = scipy.__version__
        metadata['psyFunction'] = self.psyfun
        metadata['thresholdGrid'] = self.threshold.tolist()
        metadata['thresholdPrior'] = self.thresholdPrior
        metadata['slopeGrid'] = self.slope.tolist()
        metadata['slopePrior'] = self.slopePrior
        metadata['gammaGrid'] = self.guessRate.tolist()
        metadata['gammaPrior'] = self.guessPrior
        metadata['lapseGrid'] = self.lapseRate.tolist()
        metadata['lapsePrior'] = self.lapsePrior
        return metadata
nosetester.py 文件源码 项目:radar 作者: amoose136 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def _show_system_info(self):
        nose = import_nose()

        import numpy
        print("NumPy version %s" % numpy.__version__)
        relaxed_strides = numpy.ones((10, 1), order="C").flags.f_contiguous
        print("NumPy relaxed strides checking option:", relaxed_strides)
        npdir = os.path.dirname(numpy.__file__)
        print("NumPy is installed in %s" % npdir)

        if 'scipy' in self.package_name:
            import scipy
            print("SciPy version %s" % scipy.__version__)
            spdir = os.path.dirname(scipy.__file__)
            print("SciPy is installed in %s" % spdir)

        pyversion = sys.version.replace('\n', '')
        print("Python version %s" % pyversion)
        print("nose version %d.%d.%d" % nose.__versioninfo__)
hooks.py 文件源码 项目:pystudio 作者: satorchi 项目源码 文件源码 阅读 40 收藏 0 点赞 0 评论 0
def _has_cython(self):
        extensions = self.distribution.ext_modules
        if not USE_CYTHON or not any(_.endswith('.pyx')
                                     for ext in extensions
                                     for _ in ext.sources):
            return False
        try:
            import Cython
        except ImportError:
            print('Cython is not installed, defaulting to C/C++ files.')
            return False
        if parse_version(Cython.__version__) < \
           parse_version(MIN_VERSION_CYTHON):
            print("The Cython version is older than that required ('{0}' < '{1"
                  "}'). Defaulting to C/C++ files."
                  .format(Cython.__version__, MIN_VERSION_CYTHON))
            return False
        return True
setup.py 文件源码 项目:lap 作者: gatagat 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def get_numpy_status():
    """
    Returns a dictionary containing a boolean specifying whether NumPy
    is up-to-date, along with the version string (empty string if
    not installed).
    """
    numpy_status = {}
    try:
        import numpy
        numpy_version = numpy.__version__
        numpy_status['up_to_date'] = parse_version(
            numpy_version) >= parse_version(NUMPY_MIN_VERSION)
        numpy_status['version'] = numpy_version
    except ImportError:
        traceback.print_exc()
        numpy_status['up_to_date'] = False
        numpy_status['version'] = ""
    return numpy_status
nosetester.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def _show_system_info(self):
        nose = import_nose()

        import numpy
        print("NumPy version %s" % numpy.__version__)
        relaxed_strides = numpy.ones((10, 1), order="C").flags.f_contiguous
        print("NumPy relaxed strides checking option:", relaxed_strides)
        npdir = os.path.dirname(numpy.__file__)
        print("NumPy is installed in %s" % npdir)

        if 'scipy' in self.package_name:
            import scipy
            print("SciPy version %s" % scipy.__version__)
            spdir = os.path.dirname(scipy.__file__)
            print("SciPy is installed in %s" % spdir)

        pyversion = sys.version.replace('\n', '')
        print("Python version %s" % pyversion)
        print("nose version %d.%d.%d" % nose.__versioninfo__)
yt_array.py 文件源码 项目:yt 作者: yt-project 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def unorm(data, ord=None, axis=None, keepdims=False):
    """Matrix or vector norm that preserves units

    This is a wrapper around np.linalg.norm that preserves units. See
    the documentation for that function for descriptions of the keyword
    arguments.

    The keepdims argument is ignored if the version of numpy installed is
    older than numpy 1.10.0.
    """
    if LooseVersion(np.__version__) < LooseVersion('1.10.0'):
        norm = np.linalg.norm(data, ord=ord, axis=axis)
    else:
        norm = np.linalg.norm(data, ord=ord, axis=axis, keepdims=keepdims)
    if norm.shape == ():
        return YTQuantity(norm, data.units)
    return YTArray(norm, data.units)
music_processor.py 文件源码 项目:aurora-sdk-win 作者: nanoleaf 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def check_min_versions():
    ret = True

    # pyaudio
    vers_required = "0.2.7"
    vers_current = pyaudio.__version__
    if StrictVersion(vers_current) < StrictVersion(vers_required):
        print("Error: minimum pyaudio vers: {}, current vers {}".format(vers_required, vers_current))
        ret = False

    # librosa
    vers_required = "0.4.3"
    vers_current = librosa.__version__
    if StrictVersion(vers_current) < StrictVersion(vers_required):
        print("Error: minimum librosa vers: {}, current vers {}".format(vers_required, vers_current))
        ret = False

    # numpy
    vers_required = "1.9.0"
    vers_current = np.__version__
    if StrictVersion(vers_current) < StrictVersion(vers_required):
        print("Error: minimum numpy vers: {}, current vers {}".format(vers_required, vers_current))
        ret = False

    return ret
setupext.py 文件源码 项目:SlackBuilds 作者: montagdude 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def check(self):
        try:
            import dateutil
        except ImportError:
            # dateutil 2.1 has a file encoding bug that breaks installation on
            # python 3.3
            # https://github.com/matplotlib/matplotlib/issues/2373
            # hack around the problem by installing the (working) v2.0
            #major, minor1, _, _, _ = sys.version_info
            #if self.version is None and (major, minor1) == (3, 3):
                #self.version = '!=2.1'

            raise CheckFailed (
                    "could not be found")

        major, minor1, _, _, _ = sys.version_info
        if dateutil.__version__ == '2.1' and (major, minor1) == (3, 3):
            raise CheckFailed (
                    "dateutil v. 2.1 has a bug that breaks installation"
                    "on python 3.3.x, use another dateutil version")
        return "using dateutil version %s" % dateutil.__version__
setupext.py 文件源码 项目:SlackBuilds 作者: montagdude 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def check(self):
        try:
            import pyparsing
        except ImportError:
            raise CheckFailed(
                "could not be found")

        required = [1, 5, 6]
        if [int(x) for x in pyparsing.__version__.split('.')] < required:
            raise CheckFailed(
                "matplotlib requires pyparsing >= {0}".format(
                    '.'.join(str(x) for x in required)))

        if not self.is_ok():
            return (
                "Your pyparsing contains a bug that will be monkey-patched by "
                "matplotlib.  For best results, upgrade to pyparsing 2.0.1 or "
                "later.")

        return "using pyparsing version %s" % pyparsing.__version__
__init__.py 文件源码 项目:gym-pull 作者: ppaquette 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def sanity_check_dependencies():
    import numpy
    import requests
    import six

    if distutils.version.LooseVersion(numpy.__version__) < distutils.version.LooseVersion('1.10.4'):
        logger.warn("You have 'numpy' version %s installed, but 'gym' requires at least 1.10.4. HINT: upgrade via 'pip install -U numpy'.", numpy.__version__)

    if distutils.version.LooseVersion(requests.__version__) < distutils.version.LooseVersion('2.0'):
        logger.warn("You have 'requests' version %s installed, but 'gym' requires at least 2.0. HINT: upgrade via 'pip install -U requests'.", requests.__version__)

# We automatically configure a logger with a simple stderr handler. If
# you'd rather customize logging yourself, run undo_logger_setup.
#
# (Note: this needs to happen before importing the rest of gym, since
# we may print a warning at load time.)
pymod_os_specific.py 文件源码 项目:pymod 作者: pymodproject 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def check_biopython(raise_exception_on_fail=False):
    # Unpatched Bio.PDB requires md5, which was missing in PyMOL1.2/1.3
    # because its Python2.5 was not linked against OpenSSL libraries
    if not raise_exception_on_fail:
        try:
            import Bio.PDB, Bio, Bio.Phylo # Phylo was missing in PyMOL1.5
            from Bio.Align.Applications import ClustalwCommandline # This was missing in PyMOL 1.4.
            from Bio.Align.Applications import MuscleCommandline
            return Bio.__version__, Bio.__file__
        except:
            return "",""
    else:
        import Bio.PDB, Bio, Bio.Phylo
        from Bio.Align.Applications import ClustalwCommandline
        from Bio.Align.Applications import MuscleCommandline
        return Bio.__version__, Bio.__file__
test_common.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_nan_to_nat_conversions():

    df = DataFrame(dict({
        'A': np.asarray(
            lrange(10), dtype='float64'),
        'B': Timestamp('20010101')
    }))
    df.iloc[3:6, :] = np.nan
    result = df.loc[4, 'B'].value
    assert (result == iNaT)

    s = df['B'].copy()
    s._data = s._data.setitem(indexer=tuple([slice(8, 9)]), value=np.nan)
    assert (isnull(s[8]))

    # numpy < 1.7.0 is wrong
    from distutils.version import LooseVersion
    if LooseVersion(np.__version__) >= '1.7.0':
        assert (s[8].value == np.datetime64('NaT').astype(np.int64))
test_categorical.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 41 收藏 0 点赞 0 评论 0
def test_constructor_unsortable(self):

        # it works!
        arr = np.array([1, 2, 3, datetime.now()], dtype='O')
        factor = Categorical.from_array(arr, ordered=False)
        self.assertFalse(factor.ordered)

        if compat.PY3:
            self.assertRaises(
                TypeError, lambda: Categorical.from_array(arr, ordered=True))
        else:
            # this however will raise as cannot be sorted (on PY3 or older
            # numpies)
            if LooseVersion(np.__version__) < "1.10":
                self.assertRaises(
                    TypeError,
                    lambda: Categorical.from_array(arr, ordered=True))
            else:
                Categorical.from_array(arr, ordered=True)
nosetester.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def _show_system_info(self):
        nose = import_nose()

        import numpy
        print("NumPy version %s" % numpy.__version__)
        relaxed_strides = numpy.ones((10, 1), order="C").flags.f_contiguous
        print("NumPy relaxed strides checking option:", relaxed_strides)
        npdir = os.path.dirname(numpy.__file__)
        print("NumPy is installed in %s" % npdir)

        if 'scipy' in self.package_name:
            import scipy
            print("SciPy version %s" % scipy.__version__)
            spdir = os.path.dirname(scipy.__file__)
            print("SciPy is installed in %s" % spdir)

        pyversion = sys.version.replace('\n', '')
        print("Python version %s" % pyversion)
        print("nose version %d.%d.%d" % nose.__versioninfo__)
test_numexpr.py 文件源码 项目:zorro 作者: C-CINA 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def print_versions():
    """Print the versions of software that numexpr relies on."""
    from pkg_resources import parse_version
    if parse_version(np.__version__) < parse_version(minimum_numpy_version):
        print("*Warning*: NumPy version is lower than recommended: %s < %s" % \
              (np.__version__, minimum_numpy_version))
    print('-=' * 38)
    print("Numexpr version:   %s" % numexpr.__version__)
    print("NumPy version:     %s" % np.__version__)
    print('Python version:    %s' % sys.version)
    if os.name == 'posix':
        (sysname, nodename, release, version, machine) = os.uname()
        print('Platform:          %s-%s' % (sys.platform, machine))
    print("AMD/Intel CPU?     %s" % numexpr.is_cpu_amd_intel)
    print("VML available?     %s" % use_vml)
    if use_vml:
        print("VML/MKL version:   %s" % numexpr.get_vml_version())
    print("Number of threads used by default: %d "
          "(out of %d detected cores)" % (numexpr.nthreads, numexpr.ncores))
    print('-=' * 38)
nosetester.py 文件源码 项目:aws-lambda-numpy 作者: vitolimandibhrata 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def _show_system_info(self):
        nose = import_nose()

        import numpy
        print("NumPy version %s" % numpy.__version__)
        relaxed_strides = numpy.ones((10, 1), order="C").flags.f_contiguous
        print("NumPy relaxed strides checking option:", relaxed_strides)
        npdir = os.path.dirname(numpy.__file__)
        print("NumPy is installed in %s" % npdir)

        if 'scipy' in self.package_name:
            import scipy
            print("SciPy version %s" % scipy.__version__)
            spdir = os.path.dirname(scipy.__file__)
            print("SciPy is installed in %s" % spdir)

        pyversion = sys.version.replace('\n', '')
        print("Python version %s" % pyversion)
        print("nose version %d.%d.%d" % nose.__versioninfo__)
setup.py 文件源码 项目:operalib 作者: operalib 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_scipy_status():
    """
    Return a dictionary containing a boolean specifying whether SciPy
    is up-to-date, along with the version string (empty string if
    not installed).
    """
    scipy_status = {}
    try:
        import scipy
        scipy_version = scipy.__version__
        scipy_status['up_to_date'] = parse_version(
            scipy_version) >= parse_version(scipy_min_version)
        scipy_status['version'] = scipy_version
    except ImportError:
        scipy_status['up_to_date'] = False
        scipy_status['version'] = ""
    return scipy_status
setup.py 文件源码 项目:operalib 作者: operalib 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def get_numpy_status():
    """
    Return a dictionary containing a boolean specifying whether NumPy
    is up-to-date, along with the version string (empty string if
    not installed).
    """
    numpy_status = {}
    try:
        import numpy
        numpy_version = numpy.__version__
        numpy_status['up_to_date'] = parse_version(
            numpy_version) >= parse_version(numpy_min_version)
        numpy_status['version'] = numpy_version
    except ImportError:
        numpy_status['up_to_date'] = False
        numpy_status['version'] = ""
    return numpy_status
nosetester.py 文件源码 项目:lambda-numba 作者: rlhotovy 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def _show_system_info(self):
        nose = import_nose()

        import numpy
        print("NumPy version %s" % numpy.__version__)
        relaxed_strides = numpy.ones((10, 1), order="C").flags.f_contiguous
        print("NumPy relaxed strides checking option:", relaxed_strides)
        npdir = os.path.dirname(numpy.__file__)
        print("NumPy is installed in %s" % npdir)

        if 'scipy' in self.package_name:
            import scipy
            print("SciPy version %s" % scipy.__version__)
            spdir = os.path.dirname(scipy.__file__)
            print("SciPy is installed in %s" % spdir)

        pyversion = sys.version.replace('\n', '')
        print("Python version %s" % pyversion)
        print("nose version %d.%d.%d" % nose.__versioninfo__)
nosetester.py 文件源码 项目:deliver 作者: orchestor 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def _show_system_info(self):
        nose = import_nose()

        import numpy
        print("NumPy version %s" % numpy.__version__)
        relaxed_strides = numpy.ones((10, 1), order="C").flags.f_contiguous
        print("NumPy relaxed strides checking option:", relaxed_strides)
        npdir = os.path.dirname(numpy.__file__)
        print("NumPy is installed in %s" % npdir)

        if 'scipy' in self.package_name:
            import scipy
            print("SciPy version %s" % scipy.__version__)
            spdir = os.path.dirname(scipy.__file__)
            print("SciPy is installed in %s" % spdir)

        pyversion = sys.version.replace('\n', '')
        print("Python version %s" % pyversion)
        print("nose version %d.%d.%d" % nose.__versioninfo__)
test_shared_randomstreams.py 文件源码 项目:Theano-Deep-learning 作者: GeekLiB 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def test_choice(self):
        """Test that RandomStreams.choice generates the same results as numpy"""
        # numpy.random.choice is only available for numpy versions >= 1.7
        major, minor, _ = numpy.version.short_version.split('.')
        if (int(major), int(minor)) < (1, 7):
            raise utt.SkipTest('choice requires at NumPy version >= 1.7 '
                               '(%s)' % numpy.__version__)

        # Check over two calls to see if the random state is correctly updated.
        random = RandomStreams(utt.fetch_seed())
        fn = function([], random.choice((11, 8), 10, 1, 0))
        fn_val0 = fn()
        fn_val1 = fn()

        rng_seed = numpy.random.RandomState(utt.fetch_seed()).randint(2**30)
        rng = numpy.random.RandomState(int(rng_seed))  # int() is for 32bit
        numpy_val0 = rng.choice(10, (11, 8), True, None)
        numpy_val1 = rng.choice(10, (11, 8), True, None)

        assert numpy.all(fn_val0 == numpy_val0)
        assert numpy.all(fn_val1 == numpy_val1)
test_fixes.py 文件源码 项目:decoding_challenge_cortana_2016_3rd 作者: kingjr 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def test_unique():
    """Test unique() replacement
    """
    # skip test for np version < 1.5
    if LooseVersion(np.__version__) < LooseVersion('1.5'):
        return
    for arr in [np.array([]), rng.rand(10), np.ones(10)]:
        # basic
        assert_array_equal(np.unique(arr), _unique(arr))
        # with return_index=True
        x1, x2 = np.unique(arr, return_index=True, return_inverse=False)
        y1, y2 = _unique(arr, return_index=True, return_inverse=False)
        assert_array_equal(x1, y1)
        assert_array_equal(x2, y2)
        # with return_inverse=True
        x1, x2 = np.unique(arr, return_index=False, return_inverse=True)
        y1, y2 = _unique(arr, return_index=False, return_inverse=True)
        assert_array_equal(x1, y1)
        assert_array_equal(x2, y2)
        # with both:
        x1, x2, x3 = np.unique(arr, return_index=True, return_inverse=True)
        y1, y2, y3 = _unique(arr, return_index=True, return_inverse=True)
        assert_array_equal(x1, y1)
        assert_array_equal(x2, y2)
        assert_array_equal(x3, y3)
video.py 文件源码 项目:rl-teacher 作者: nottombrown 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def capture_frame(self, frame):
        if not isinstance(frame, (np.ndarray, np.generic)):
            raise error.InvalidFrame(
                'Wrong type {} for {} (must be np.ndarray or np.generic)'.format(type(frame), frame))
        if frame.shape != self.frame_shape:
            raise error.InvalidFrame(
                "Your frame has shape {}, but the VideoRecorder is configured for shape {}.".format(
                    frame.shape, self.frame_shape))
        if frame.dtype != np.uint8:
            raise error.InvalidFrame(
                "Your frame has data type {}, but we require uint8 (i.e. RGB values from 0-255).".format(frame.dtype))

        if distutils.version.LooseVersion(np.__version__) >= distutils.version.LooseVersion('1.9.0'):
            self.proc.stdin.write(frame.tobytes())
        else:
            self.proc.stdin.write(frame.tostring())
setup.py 文件源码 项目:Parallel-SGD 作者: angadgill 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_scipy_status():
    """
    Returns a dictionary containing a boolean specifying whether SciPy
    is up-to-date, along with the version string (empty string if
    not installed).
    """
    scipy_status = {}
    try:
        import scipy
        scipy_version = scipy.__version__
        scipy_status['up_to_date'] = parse_version(
            scipy_version) >= parse_version(scipy_min_version)
        scipy_status['version'] = scipy_version
    except ImportError:
        scipy_status['up_to_date'] = False
        scipy_status['version'] = ""
    return scipy_status
setup.py 文件源码 项目:Parallel-SGD 作者: angadgill 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def get_numpy_status():
    """
    Returns a dictionary containing a boolean specifying whether NumPy
    is up-to-date, along with the version string (empty string if
    not installed).
    """
    numpy_status = {}
    try:
        import numpy
        numpy_version = numpy.__version__
        numpy_status['up_to_date'] = parse_version(
            numpy_version) >= parse_version(numpy_min_version)
        numpy_status['version'] = numpy_version
    except ImportError:
        numpy_status['up_to_date'] = False
        numpy_status['version'] = ""
    return numpy_status
nosetester.py 文件源码 项目:Alfred 作者: jkachhadia 项目源码 文件源码 阅读 42 收藏 0 点赞 0 评论 0
def _show_system_info(self):
        nose = import_nose()

        import numpy
        print("NumPy version %s" % numpy.__version__)
        relaxed_strides = numpy.ones((10, 1), order="C").flags.f_contiguous
        print("NumPy relaxed strides checking option:", relaxed_strides)
        npdir = os.path.dirname(numpy.__file__)
        print("NumPy is installed in %s" % npdir)

        if 'scipy' in self.package_name:
            import scipy
            print("SciPy version %s" % scipy.__version__)
            spdir = os.path.dirname(scipy.__file__)
            print("SciPy is installed in %s" % spdir)

        pyversion = sys.version.replace('\n', '')
        print("Python version %s" % pyversion)
        print("nose version %d.%d.%d" % nose.__versioninfo__)
music_processor.py 文件源码 项目:aurora-sdk-mac 作者: nanoleaf 项目源码 文件源码 阅读 43 收藏 0 点赞 0 评论 0
def check_min_versions():
    ret = True

    # pyaudio
    vers_required = "0.2.7"
    vers_current = pyaudio.__version__
    if StrictVersion(vers_current) < StrictVersion(vers_required):
        print("Error: minimum pyaudio vers: {}, current vers {}".format(vers_required, vers_current))
        ret = False

    # librosa
    vers_required = "0.4.3"
    vers_current = librosa.__version__
    if StrictVersion(vers_current) < StrictVersion(vers_required):
        print("Error: minimum librosa vers: {}, current vers {}".format(vers_required, vers_current))
        ret = False

    # numpy
    vers_required = "1.9.0"
    vers_current = np.__version__
    if StrictVersion(vers_current) < StrictVersion(vers_required):
        print("Error: minimum numpy vers: {}, current vers {}".format(vers_required, vers_current))
        ret = False

    return ret
generic.py 文件源码 项目:DBAdapter 作者: ContinuumIO 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_timestamp_dictarray(self):
        if np.__version__ < "1.7": return
        self.cursor.execute("create table t1(a int, b timestamp, c int)")

        dates = [datetime.strptime("2008-04-%02d 00:01:02"%i, "%Y-%m-%d %H:%M:%S")
                 for i in range(1,11)]

        params = [ (i, dates[i-1], i) for i in range(1,11) ]
        npparams = [ (i, np.datetime64(dates[i-1]), i) for i in range(1,11) ]

        self.cursor.executemany("insert into t1(a, b, c) values (?,?,?)", params)

        self.cursor.execute("select a, b, c from t1 order by a")
        rows = self.cursor.fetchdictarray()
        for param, row in zip(npparams, zip(rows['a'], rows['b'], rows['c'])):
            self.assertEqual(param[0], row[0])
            self.assertEqual(param[1], row[1])
            self.assertEqual(param[2], row[2])
generic.py 文件源码 项目:DBAdapter 作者: ContinuumIO 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def test_timestamp_sarray(self):
        if np.__version__ < "1.7": return
        self.cursor.execute("create table t1(a int, b timestamp, c int)")

        dates = [datetime.strptime("2008-04-%02d 00:01:02"%i, "%Y-%m-%d %H:%M:%S")
                 for i in range(1,11)]

        params = [ (i, dates[i-1], i) for i in range(1,11) ]
        npparams = [ (i, np.datetime64(dates[i-1]), i) for i in range(1,11) ]

        self.cursor.executemany("insert into t1(a, b, c) values (?,?,?)", params)

        self.cursor.execute("select a, b, c from t1 order by a")
        rows = self.cursor.fetchsarray()
        for param, row in zip(npparams, rows):
            self.assertEqual(param[0], row[0])
            self.assertEqual(param[1], row[1])
            self.assertEqual(param[2], row[2])
generic.py 文件源码 项目:DBAdapter 作者: ContinuumIO 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_date_dictarray(self):
        if np.__version__ < "1.7": return
        self.cursor.execute("create table t1(a int, b date, c int)")

        dates = [date(2008, 4, i) for i in range(1,11)]
        npdates = np.array(dates, dtype='datetime64[D]')

        params = [ (i, dates[i-1], i) for i in range(1,11) ]
        npparams = [ (i, npdates[i-1], i) for i in range(1,11) ]

        self.cursor.executemany("insert into t1(a, b, c) values (?,?,?)", params)

        self.cursor.execute("select a, b, c from t1 order by a")
        rows = self.cursor.fetchdictarray()
        for param, row in zip(npparams, zip(rows['a'], rows['b'], rows['c'])):
            self.assertEqual(param[0], row[0])
            self.assertEqual(param[1], row[1])
            self.assertEqual(param[2], row[2])


问题


面经


文章

微信
公众号

扫码关注公众号