Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: Improved pandas/compact/__init__.py #29507

Merged
merged 3 commits into from
Nov 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 59 additions & 5 deletions pandas/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

def set_function_name(f, name, cls):
"""
Bind the name/qualname attributes of the function
Bind the name/qualname attributes of the function.
"""
f.__name__ = name
f.__qualname__ = "{klass}.{name}".format(klass=cls.__name__, name=name)
Expand All @@ -39,28 +39,72 @@ def set_function_name(f, name, cls):

# https://github.com/pandas-dev/pandas/pull/9123
def is_platform_little_endian():
""" am I little endian """
"""
Checking if the running platform is little endian.

Returns
-------
bool
True if the running platform is little endian.
"""
return sys.byteorder == "little"


def is_platform_windows():
"""
Checking if the running platform is windows.

Returns
-------
bool
True if the running platform is windows.
"""
return sys.platform == "win32" or sys.platform == "cygwin"


def is_platform_linux():
"""
Checking if the running platform is linux.

Returns
-------
bool
True if the running platform is linux.
"""
return sys.platform == "linux2"


def is_platform_mac():
"""
Checking if the running platform is mac.

Returns
-------
bool
True if the running platform is mac.
"""
return sys.platform == "darwin"


def is_platform_32bit():
"""
Checking if the running platform is 32-bit.

Returns
-------
bool
True if the running platform is 32-bit.
"""
return struct.calcsize("P") * 8 < 64


def _import_lzma():
"""Attempts to import lzma, warning the user when lzma is not available.
"""
Attempts to import the lzma module.

Warns
-----
When the lzma module is not available.
"""
try:
import lzma
Expand All @@ -76,8 +120,18 @@ def _import_lzma():


def _get_lzma_file(lzma):
"""Returns the lzma method LZMAFile when the module was correctly imported.
Otherwise, raises a RuntimeError.
"""
Attempting to get the lzma.LZMAFile class.

Returns
-------
class
The lzma.LZMAFile class.

Raises
------
RuntimeError
If the module lzma was not imported correctly, or didn't exist.
"""
if lzma is None:
raise RuntimeError(
Expand Down