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


Python compat.is_platform_32bit方法代码示例

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


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

示例1: skipif_32bit

# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import is_platform_32bit [as 别名]
def skipif_32bit(param):
    """
    Skip parameters in a parametrize on 32bit systems. Specifically used
    here to skip leaf_size parameters related to GH 23440.
    """
    marks = pytest.mark.skipif(compat.is_platform_32bit(),
                               reason='GH 23440: int type mismatch on 32bit')
    return pytest.param(param, marks=marks) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:10,代码来源:test_interval_tree.py

示例2: test_int_max

# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import is_platform_32bit [as 别名]
def test_int_max(self, any_int_dtype):
        if any_int_dtype in ("int64", "uint64") and compat.is_platform_32bit():
            pytest.skip("Cannot test 64-bit integer on 32-bit platform")

        klass = np.dtype(any_int_dtype).type

        # uint64 max will always overflow,
        # as it's encoded to signed.
        if any_int_dtype == "uint64":
            num = np.iinfo("int64").max
        else:
            num = np.iinfo(any_int_dtype).max

        assert klass(ujson.decode(ujson.encode(num))) == num 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:16,代码来源:test_ujson.py

示例3: test_dropna

# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import is_platform_32bit [as 别名]
def test_dropna(self):
        # https://github.com/pandas-dev/pandas/issues/9443#issuecomment-73719328

        tm.assert_series_equal(
            Series([True, True, False]).value_counts(dropna=True),
            Series([2, 1], index=[True, False]))
        tm.assert_series_equal(
            Series([True, True, False]).value_counts(dropna=False),
            Series([2, 1], index=[True, False]))

        tm.assert_series_equal(
            Series([True, True, False, None]).value_counts(dropna=True),
            Series([2, 1], index=[True, False]))
        tm.assert_series_equal(
            Series([True, True, False, None]).value_counts(dropna=False),
            Series([2, 1, 1], index=[True, False, np.nan]))
        tm.assert_series_equal(
            Series([10.3, 5., 5.]).value_counts(dropna=True),
            Series([2, 1], index=[5., 10.3]))
        tm.assert_series_equal(
            Series([10.3, 5., 5.]).value_counts(dropna=False),
            Series([2, 1], index=[5., 10.3]))

        tm.assert_series_equal(
            Series([10.3, 5., 5., None]).value_counts(dropna=True),
            Series([2, 1], index=[5., 10.3]))

        # 32-bit linux has a different ordering
        if not compat.is_platform_32bit():
            result = Series([10.3, 5., 5., None]).value_counts(dropna=False)
            expected = Series([2, 1, 1], index=[5., 10.3, np.nan])
            tm.assert_series_equal(result, expected) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:34,代码来源:test_algos.py

示例4: test_value_counts_uint64

# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import is_platform_32bit [as 别名]
def test_value_counts_uint64(self):
        arr = np.array([2**63], dtype=np.uint64)
        expected = Series([1], index=[2**63])
        result = algos.value_counts(arr)

        tm.assert_series_equal(result, expected)

        arr = np.array([-1, 2**63], dtype=object)
        expected = Series([1, 1], index=[-1, 2**63])
        result = algos.value_counts(arr)

        # 32-bit linux has a different ordering
        if not compat.is_platform_32bit():
            tm.assert_series_equal(result, expected) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:16,代码来源:test_algos.py

示例5: test_itertuples

# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import is_platform_32bit [as 别名]
def test_itertuples(self):
        for i, tup in enumerate(self.frame.itertuples()):
            s = self.klass._constructor_sliced(tup[1:])
            s.name = tup[0]
            expected = self.frame.iloc[i, :].reset_index(drop=True)
            self._assert_series_equal(s, expected)

        df = self.klass({'floats': np.random.randn(5),
                         'ints': lrange(5)}, columns=['floats', 'ints'])

        for tup in df.itertuples(index=False):
            assert isinstance(tup[1], (int, long))

        df = self.klass(data={"a": [1, 2, 3], "b": [4, 5, 6]})
        dfaa = df[['a', 'a']]

        assert (list(dfaa.itertuples()) ==
                [(0, 1, 1), (1, 2, 2), (2, 3, 3)])

        # repr with be int/long on 32-bit/windows
        if not (compat.is_platform_windows() or compat.is_platform_32bit()):
            assert (repr(list(df.itertuples(name=None))) ==
                    '[(0, 1, 4), (1, 2, 5), (2, 3, 6)]')

        tup = next(df.itertuples(name='TestName'))
        assert tup._fields == ('Index', 'a', 'b')
        assert (tup.Index, tup.a, tup.b) == tup
        assert type(tup).__name__ == 'TestName'

        df.columns = ['def', 'return']
        tup2 = next(df.itertuples(name='TestName'))
        assert tup2 == (0, 1, 4)
        assert tup2._fields == ('Index', '_1', '_2')

        df3 = DataFrame({'f' + str(i): [i] for i in range(1024)})
        # will raise SyntaxError if trying to create namedtuple
        tup3 = next(df3.itertuples())
        assert not hasattr(tup3, '_fields')
        assert isinstance(tup3, tuple) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:41,代码来源:test_api.py

示例6: test_IntMax

# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import is_platform_32bit [as 别名]
def test_IntMax(self):
        num = np.int(np.iinfo(np.int).max)
        assert np.int(ujson.decode(ujson.encode(num))) == num

        num = np.int8(np.iinfo(np.int8).max)
        assert np.int8(ujson.decode(ujson.encode(num))) == num

        num = np.int16(np.iinfo(np.int16).max)
        assert np.int16(ujson.decode(ujson.encode(num))) == num

        num = np.int32(np.iinfo(np.int32).max)
        assert np.int32(ujson.decode(ujson.encode(num))) == num

        num = np.uint8(np.iinfo(np.uint8).max)
        assert np.uint8(ujson.decode(ujson.encode(num))) == num

        num = np.uint16(np.iinfo(np.uint16).max)
        assert np.uint16(ujson.decode(ujson.encode(num))) == num

        num = np.uint32(np.iinfo(np.uint32).max)
        assert np.uint32(ujson.decode(ujson.encode(num))) == num

        if not compat.is_platform_32bit():
            num = np.int64(np.iinfo(np.int64).max)
            assert np.int64(ujson.decode(ujson.encode(num))) == num

            # uint64 max will always overflow as it's encoded to signed
            num = np.uint64(np.iinfo(np.int64).max)
            assert np.uint64(ujson.decode(ujson.encode(num))) == num 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:31,代码来源:test_ujson.py

示例7: _assert_replace_conversion

# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import is_platform_32bit [as 别名]
def _assert_replace_conversion(self, from_key, to_key, how):
        index = pd.Index([3, 4], name='xxx')
        obj = pd.Series(self.rep[from_key], index=index, name='yyy')
        assert obj.dtype == from_key

        if (from_key.startswith('datetime') and to_key.startswith('datetime')):
            # different tz, currently mask_missing raises SystemError
            return

        if how == 'dict':
            replacer = dict(zip(self.rep[from_key], self.rep[to_key]))
        elif how == 'series':
            replacer = pd.Series(self.rep[to_key], index=self.rep[from_key])
        else:
            raise ValueError

        result = obj.replace(replacer)

        if ((from_key == 'float64' and to_key in ('int64')) or
            (from_key == 'complex128' and
             to_key in ('int64', 'float64'))):

            # buggy on 32-bit / window
            if compat.is_platform_32bit() or compat.is_platform_windows():
                pytest.skip("32-bit platform buggy: {0} -> {1}".format
                            (from_key, to_key))

            # Expected: do not downcast by replacement
            exp = pd.Series(self.rep[to_key], index=index,
                            name='yyy', dtype=from_key)

        else:
            exp = pd.Series(self.rep[to_key], index=index, name='yyy')
            assert exp.dtype == to_key

        tm.assert_series_equal(result, exp) 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:38,代码来源:test_coercion.py

示例8: test_replace_series

# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import is_platform_32bit [as 别名]
def test_replace_series(self, how, to_key, from_key):
        if from_key == 'bool' and how == 'series' and compat.PY3:
            # doesn't work in PY3, though ...dict_from_bool works fine
            pytest.skip("doesn't work as in PY3")

        index = pd.Index([3, 4], name='xxx')
        obj = pd.Series(self.rep[from_key], index=index, name='yyy')
        assert obj.dtype == from_key

        if (from_key.startswith('datetime') and to_key.startswith('datetime')):
            # tested below
            return
        elif from_key in ['datetime64[ns, US/Eastern]', 'datetime64[ns, UTC]']:
            # tested below
            return

        if how == 'dict':
            replacer = dict(zip(self.rep[from_key], self.rep[to_key]))
        elif how == 'series':
            replacer = pd.Series(self.rep[to_key], index=self.rep[from_key])
        else:
            raise ValueError

        result = obj.replace(replacer)

        if ((from_key == 'float64' and to_key in ('int64')) or
            (from_key == 'complex128' and
             to_key in ('int64', 'float64'))):

            if compat.is_platform_32bit() or compat.is_platform_windows():
                pytest.skip("32-bit platform buggy: {0} -> {1}".format
                            (from_key, to_key))

            # Expected: do not downcast by replacement
            exp = pd.Series(self.rep[to_key], index=index,
                            name='yyy', dtype=from_key)

        else:
            exp = pd.Series(self.rep[to_key], index=index, name='yyy')
            assert exp.dtype == to_key

        tm.assert_series_equal(result, exp)

    # TODO(jbrockmendel) commented out to only have a single xfail printed 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:46,代码来源:test_coercion.py

示例9: test_itertuples

# 需要导入模块: from pandas import compat [as 别名]
# 或者: from pandas.compat import is_platform_32bit [as 别名]
def test_itertuples(self):
        for i, tup in enumerate(self.frame.itertuples()):
            s = self.klass._constructor_sliced(tup[1:])
            s.name = tup[0]
            expected = self.frame.iloc[i, :].reset_index(drop=True)
            self._assert_series_equal(s, expected)

        df = self.klass({'floats': np.random.randn(5),
                         'ints': lrange(5)}, columns=['floats', 'ints'])

        for tup in df.itertuples(index=False):
            assert isinstance(tup[1], (int, long))

        df = self.klass(data={"a": [1, 2, 3], "b": [4, 5, 6]})
        dfaa = df[['a', 'a']]

        assert (list(dfaa.itertuples()) ==
                [(0, 1, 1), (1, 2, 2), (2, 3, 3)])

        # repr with be int/long on 32-bit/windows
        if not (compat.is_platform_windows() or compat.is_platform_32bit()):
            assert (repr(list(df.itertuples(name=None))) ==
                    '[(0, 1, 4), (1, 2, 5), (2, 3, 6)]')

        tup = next(df.itertuples(name='TestName'))

        if sys.version >= LooseVersion('2.7'):
            assert tup._fields == ('Index', 'a', 'b')
            assert (tup.Index, tup.a, tup.b) == tup
            assert type(tup).__name__ == 'TestName'

        df.columns = ['def', 'return']
        tup2 = next(df.itertuples(name='TestName'))
        assert tup2 == (0, 1, 4)

        if sys.version >= LooseVersion('2.7'):
            assert tup2._fields == ('Index', '_1', '_2')

        df3 = DataFrame(dict(('f' + str(i), [i]) for i in range(1024)))
        # will raise SyntaxError if trying to create namedtuple
        tup3 = next(df3.itertuples())
        assert not hasattr(tup3, '_fields')
        assert isinstance(tup3, tuple) 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:45,代码来源:test_api.py


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