当前位置: 首页>>代码示例>>Python>>正文


Python version.LooseVersion方法代码示例

本文整理汇总了Python中distutils.version.LooseVersion方法的典型用法代码示例。如果您正苦于以下问题:Python version.LooseVersion方法的具体用法?Python version.LooseVersion怎么用?Python version.LooseVersion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在distutils.version的用法示例。


在下文中一共展示了version.LooseVersion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _is_latest_version

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import LooseVersion [as 别名]
def _is_latest_version():
  """Checks if the app is up to date and sets bootstrap to incomplete if not.

  Checks whether the running version is the same as the deployed version as an
  app that is not updated should trigger bootstrap moving back to an incomplete
  state, thus signaling that certain tasks need to be run again.

  Returns:
    True if running matches deployed version and not a new install, else False.
  """
  if _is_new_deployment():
    return False

  up_to_date = version.LooseVersion(
      constants.APP_VERSION) == version.LooseVersion(
          config_model.Config.get('running_version'))

  if not up_to_date and not is_bootstrap_started():
    # Set the updates tasks to incomplete so that they run again.
    config_model.Config.set('bootstrap_completed', False)
    for task in _BOOTSTRAP_UPDATE_TASKS:
      status_entity = bootstrap_status_model.BootstrapStatus.get_or_insert(task)
      status_entity.success = False
      status_entity.put()
  return up_to_date 
开发者ID:google,项目名称:loaner,代码行数:27,代码来源:bootstrap.py

示例2: resize

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import LooseVersion [as 别名]
def resize(image, output_shape, order=1, mode='constant', cval=0, clip=True,
           preserve_range=False, anti_aliasing=False, anti_aliasing_sigma=None):
    """A wrapper for Scikit-Image resize().
    Scikit-Image generates warnings on every call to resize() if it doesn't
    receive the right parameters. The right parameters depend on the version
    of skimage. This solves the problem by using different parameters per
    version. And it provides a central place to control resizing defaults.
    """
    if LooseVersion(skimage.__version__) >= LooseVersion("0.14"):
        # New in 0.14: anti_aliasing. Default it to False for backward
        # compatibility with skimage 0.13.
        return skimage.transform.resize(
            image, output_shape,
            order=order, mode=mode, cval=cval, clip=clip,
            preserve_range=preserve_range, anti_aliasing=anti_aliasing,
            anti_aliasing_sigma=anti_aliasing_sigma)
    else:
        return skimage.transform.resize(
            image, output_shape,
            order=order, mode=mode, cval=cval, clip=clip,
            preserve_range=preserve_range) 
开发者ID:dataiku,项目名称:dataiku-contrib,代码行数:23,代码来源:utils.py

示例3: _compare_versions

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import LooseVersion [as 别名]
def _compare_versions(self, a, b):

        ''' -1 a is smaller
            1 a is larger
            0 equal
        '''
        a = LooseVersion(a)
        b = LooseVersion(b)

        if a < b:
            return -1

        if a > b:
            return 1
        
        return 0 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:18,代码来源:connection_manager.py

示例4: compare_version

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import LooseVersion [as 别名]
def compare_version(a, b):

    ''' -1 a is smaller
        1 a is larger
        0 equal
    '''
    a = LooseVersion(a)
    b = LooseVersion(b)

    if a < b:
        return -1

    if a > b:
        return 1

    return 0 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:18,代码来源:utils.py

示例5: GetTrack

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import LooseVersion [as 别名]
def GetTrack():
  """Retrieve the currently set track.

  Returns:
    track: As defined in Track key, stable if undefined, or unstable
        if Major OS version does not match currently supported version.
  """
  major_os_version = GetMajorOSVersion()
  if not major_os_version:
    track = 'stable'
  else:
    track = MachineInfoForKey('Track')
    if distutils_version.LooseVersion(
        major_os_version) > distutils_version.LooseVersion(MAX_SUPPORTED_VERS):
      track = 'unstable'
    elif track not in ['stable', 'testing', 'unstable']:
      track = 'stable'
  return track 
开发者ID:google,项目名称:macops,代码行数:20,代码来源:gmacpyutil.py

示例6: test_read_backward_compatibility

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import LooseVersion [as 别名]
def test_read_backward_compatibility():
    """Test backwards compatibility with a pickled file that's created with Python 2.7.3,
    Numpy 1.7.1_ahl2 and Pandas 0.14.1
    """
    fname = path.join(path.dirname(__file__), "data", "test-data.pkl")

    # For newer versions; verify that unpickling fails when using cPickle
    if PANDAS_VERSION >= LooseVersion("0.16.1"):
        if sys.version_info[0] >= 3:
            with pytest.raises(UnicodeDecodeError), open(fname) as fh:
                cPickle.load(fh)
        else:
            with pytest.raises(TypeError), open(fname) as fh:
                cPickle.load(fh)

    # Verify that PickleStore() uses a backwards compatible unpickler.
    store = PickleStore()

    with open(fname) as fh:
        # PickleStore compresses data with lz4
        version = {'blob': compressHC(fh.read())}
    df = store.read(sentinel.arctic_lib, version, sentinel.symbol)

    expected = pd.DataFrame(range(4), pd.date_range(start="20150101", periods=4))
    assert (df == expected).all().all() 
开发者ID:man-group,项目名称:arctic,代码行数:27,代码来源:test_pickle_store.py

示例7: get_api_obj

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import LooseVersion [as 别名]
def get_api_obj(cls):
        """returns object to call ahv provider specific apis"""

        client = get_api_client()
        calm_version = Version.get_version("Calm")
        api_handlers = AhvBase.api_handlers

        # Return min version that is greater or equal to user calm version
        supported_versions = []
        for k in api_handlers.keys():
            if LV(k) <= LV(calm_version):
                supported_versions.append(k)

        latest_version = max(supported_versions, key=lambda x: LV(x))
        api_handler = api_handlers[latest_version]
        return api_handler(client.connection) 
开发者ID:nutanix,项目名称:calm-dsl,代码行数:18,代码来源:main.py

示例8: _plot

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import LooseVersion [as 别名]
def _plot(cls, ax, y, style=None, bw_method=None, ind=None,
              column_num=None, stacking_id=None, **kwds):
        from scipy.stats import gaussian_kde
        from scipy import __version__ as spv

        y = remove_na_arraylike(y)

        if LooseVersion(spv) >= '0.11.0':
            gkde = gaussian_kde(y, bw_method=bw_method)
        else:
            gkde = gaussian_kde(y)
            if bw_method is not None:
                msg = ('bw_method was added in Scipy 0.11.0.' +
                       ' Scipy version in use is {spv}.'.format(spv=spv))
                warnings.warn(msg)

        y = gkde.evaluate(ind)
        lines = MPLPlot._plot(ax, ind, y, style=style, **kwds)
        return lines 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:_core.py

示例9: test_fallback_plural

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import LooseVersion [as 别名]
def test_fallback_plural(self):
        # test moving from daylight savings to standard time
        import dateutil
        for tz, utc_offsets in self.timezone_utc_offsets.items():
            hrs_pre = utc_offsets['utc_offset_daylight']
            hrs_post = utc_offsets['utc_offset_standard']

            if LooseVersion(dateutil.__version__) < LooseVersion('2.6.0'):
                # buggy ambiguous behavior in 2.6.0
                # GH 14621
                # https://github.com/dateutil/dateutil/issues/321
                self._test_all_offsets(
                    n=3, tstart=self._make_timestamp(self.ts_pre_fallback,
                                                     hrs_pre, tz),
                    expected_utc_offset=hrs_post)
            elif LooseVersion(dateutil.__version__) > LooseVersion('2.6.0'):
                # fixed, but skip the test
                continue 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:20,代码来源:test_offsets.py

示例10: test_invalid_numexpr_version

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import LooseVersion [as 别名]
def test_invalid_numexpr_version(engine, parser):
    def testit():
        a, b = 1, 2  # noqa
        res = pd.eval('a + b', engine=engine, parser=parser)
        assert res == 3

    if engine == 'numexpr':
        try:
            import numexpr as ne
        except ImportError:
            pytest.skip("no numexpr")
        else:
            if (LooseVersion(ne.__version__) <
                    LooseVersion(_MIN_NUMEXPR_VERSION)):
                with pytest.raises(ImportError):
                    testit()
            else:
                testit()
    else:
        testit() 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:22,代码来源:test_compat.py

示例11: test_rank_methods_series

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import LooseVersion [as 别名]
def test_rank_methods_series(self):
        pytest.importorskip('scipy.stats.special')
        rankdata = pytest.importorskip('scipy.stats.rankdata')
        import scipy

        xs = np.random.randn(9)
        xs = np.concatenate([xs[i:] for i in range(0, 9, 2)])  # add duplicates
        np.random.shuffle(xs)

        index = [chr(ord('a') + i) for i in range(len(xs))]

        for vals in [xs, xs + 1e6, xs * 1e-6]:
            ts = Series(vals, index=index)

            for m in ['average', 'min', 'max', 'first', 'dense']:
                result = ts.rank(method=m)
                sprank = rankdata(vals, m if m != 'first' else 'ordinal')
                expected = Series(sprank, index=index)

                if LooseVersion(scipy.__version__) >= LooseVersion('0.17.0'):
                    expected = expected.astype('float64')
                tm.assert_series_equal(result, expected) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:24,代码来源:test_rank.py

示例12: test_rank_methods_frame

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import LooseVersion [as 别名]
def test_rank_methods_frame(self):
        pytest.importorskip('scipy.stats.special')
        rankdata = pytest.importorskip('scipy.stats.rankdata')
        import scipy

        xs = np.random.randint(0, 21, (100, 26))
        xs = (xs - 10.0) / 10.0
        cols = [chr(ord('z') - i) for i in range(xs.shape[1])]

        for vals in [xs, xs + 1e6, xs * 1e-6]:
            df = DataFrame(vals, columns=cols)

            for ax in [0, 1]:
                for m in ['average', 'min', 'max', 'first', 'dense']:
                    result = df.rank(axis=ax, method=m)
                    sprank = np.apply_along_axis(
                        rankdata, ax, vals,
                        m if m != 'first' else 'ordinal')
                    sprank = sprank.astype(np.float64)
                    expected = DataFrame(sprank, columns=cols)

                    if (LooseVersion(scipy.__version__) >=
                            LooseVersion('0.17.0')):
                        expected = expected.astype('float64')
                    tm.assert_frame_equal(result, expected) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:27,代码来源:test_rank.py

示例13: create_msgpack_data

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import LooseVersion [as 别名]
def create_msgpack_data():
    data = create_data()
    if _loose_version < LooseVersion('0.17.0'):
        del data['frame']['mixed_dup']
        del data['panel']['mixed_dup']
        del data['frame']['dup']
        del data['panel']['dup']
    if _loose_version < LooseVersion('0.18.0'):
        del data['series']['dt_tz']
        del data['frame']['dt_mixed_tzs']
    # Not supported
    del data['sp_series']
    del data['sp_frame']
    del data['series']['cat']
    del data['series']['period']
    del data['frame']['cat_onecol']
    del data['frame']['cat_and_float']
    del data['scalars']['period']
    if _loose_version < LooseVersion('0.23.0'):
        del data['index']['interval']
    del data['offsets']
    return _u(data) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:24,代码来源:generate_legacy_storage_files.py

示例14: __init__

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import LooseVersion [as 别名]
def __init__(self):
        # since pandas is a dependency of pyarrow
        # we need to import on first use
        try:
            import pyarrow
            import pyarrow.parquet
        except ImportError:
            raise ImportError(
                "pyarrow is required for parquet support\n\n"
                "you can install via conda\n"
                "conda install pyarrow -c conda-forge\n"
                "\nor via pip\n"
                "pip install -U pyarrow\n"
            )
        if LooseVersion(pyarrow.__version__) < '0.9.0':
            raise ImportError(
                "pyarrow >= 0.9.0 is required for parquet support\n\n"
                "you can install via conda\n"
                "conda install pyarrow -c conda-forge\n"
                "\nor via pip\n"
                "pip install -U pyarrow\n"
            )

        self.api = pyarrow 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:26,代码来源:parquet.py

示例15: _tables

# 需要导入模块: from distutils import version [as 别名]
# 或者: from distutils.version import LooseVersion [as 别名]
def _tables():
    global _table_mod
    global _table_file_open_policy_is_strict
    if _table_mod is None:
        import tables
        _table_mod = tables

        # version requirements
        if LooseVersion(tables.__version__) < LooseVersion('3.0.0'):
            raise ImportError("PyTables version >= 3.0.0 is required")

        # set the file open policy
        # return the file open policy; this changes as of pytables 3.1
        # depending on the HDF5 version
        try:
            _table_file_open_policy_is_strict = (
                tables.file._FILE_OPEN_POLICY == 'strict')
        except AttributeError:
            pass

    return _table_mod

# interface to/from ### 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:25,代码来源:pytables.py


注:本文中的distutils.version.LooseVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。