當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。