Skip to content

Commit 7e4b27f

Browse files
committed
CLN: move PerformanceWarning to io.common and clean up
1 parent 6eeff1a commit 7e4b27f

File tree

2 files changed

+50
-31
lines changed

2 files changed

+50
-31
lines changed

pandas/io/common.py

+20-14
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
_VALID_URLS.discard('')
1010

1111

12+
class PerformanceWarning(Warning):
13+
pass
14+
15+
1216
def _is_url(url):
1317
"""Check to see if a URL has a valid protocol.
1418
@@ -26,27 +30,29 @@ def _is_url(url):
2630
except:
2731
return False
2832

33+
2934
def _is_s3_url(url):
30-
""" Check for an s3 url """
35+
"""Check for an s3 url"""
3136
try:
3237
return urlparse.urlparse(url).scheme == 's3'
3338
except:
3439
return False
3540

41+
3642
def get_filepath_or_buffer(filepath_or_buffer, encoding=None):
37-
""" if the filepath_or_buffer is a url, translate and return the buffer
38-
passthru otherwise
39-
40-
Parameters
41-
----------
42-
filepath_or_buffer : a url, filepath, or buffer
43-
encoding : the encoding to use to decode py3 bytes, default is 'utf-8'
44-
45-
Returns
46-
-------
47-
a filepath_or_buffer, the encoding
48-
49-
"""
43+
"""
44+
If the filepath_or_buffer is a url, translate and return the buffer
45+
passthru otherwise.
46+
47+
Parameters
48+
----------
49+
filepath_or_buffer : a url, filepath, or buffer
50+
encoding : the encoding to use to decode py3 bytes, default is 'utf-8'
51+
52+
Returns
53+
-------
54+
a filepath_or_buffer, the encoding
55+
"""
5056

5157
if _is_url(filepath_or_buffer):
5258
from urllib2 import urlopen

pandas/io/pytables.py

+30-17
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,22 @@
1212
import warnings
1313

1414
import numpy as np
15-
from pandas import (
16-
Series, TimeSeries, DataFrame, Panel, Panel4D, Index,
17-
MultiIndex, Int64Index, Timestamp
18-
)
15+
from pandas import (Series, TimeSeries, DataFrame, Panel, Panel4D, Index,
16+
MultiIndex, Int64Index, Timestamp)
1917
from pandas.sparse.api import SparseSeries, SparseDataFrame, SparsePanel
2018
from pandas.sparse.array import BlockIndex, IntIndex
2119
from pandas.tseries.api import PeriodIndex, DatetimeIndex
22-
from pandas.core.common import adjoin, isnull, is_list_like
23-
from pandas.core.algorithms import match, unique, factorize
20+
from pandas.core.common import adjoin, is_list_like
21+
from pandas.core.algorithms import match, unique
2422
from pandas.core.categorical import Categorical
25-
from pandas.core.common import _asarray_tuplesafe, _try_sort
23+
from pandas.core.common import _asarray_tuplesafe
2624
from pandas.core.internals import BlockManager, make_block
2725
from pandas.core.reshape import block2d_to_blocknd, factor_indexer
28-
from pandas.core.index import Int64Index, _ensure_index
26+
from pandas.core.index import _ensure_index
2927
import pandas.core.common as com
3028
from pandas.tools.merge import concat
3129
from pandas.util import py3compat
30+
from pandas.io.common import PerformanceWarning
3231

3332
import pandas.lib as lib
3433
import pandas.algos as algos
@@ -42,32 +41,46 @@
4241
# PY3 encoding if we don't specify
4342
_default_encoding = 'UTF-8'
4443

44+
4545
def _ensure_decoded(s):
4646
""" if we have bytes, decode them to unicde """
4747
if isinstance(s, np.bytes_):
4848
s = s.decode('UTF-8')
4949
return s
50+
51+
5052
def _ensure_encoding(encoding):
5153
# set the encoding if we need
5254
if encoding is None:
5355
if py3compat.PY3:
5456
encoding = _default_encoding
5557
return encoding
5658

57-
class IncompatibilityWarning(Warning): pass
59+
60+
class IncompatibilityWarning(Warning):
61+
pass
62+
63+
5864
incompatibility_doc = """
59-
where criteria is being ignored as this version [%s] is too old (or not-defined),
60-
read the file in and write it out to a new file to upgrade (with the copy_to method)
65+
where criteria is being ignored as this version [%s] is too old (or
66+
not-defined), read the file in and write it out to a new file to upgrade (with
67+
the copy_to method)
6168
"""
62-
class AttributeConflictWarning(Warning): pass
69+
70+
71+
class AttributeConflictWarning(Warning):
72+
pass
73+
74+
6375
attribute_conflict_doc = """
64-
the [%s] attribute of the existing index is [%s] which conflicts with the new [%s],
65-
resetting the attribute to None
76+
the [%s] attribute of the existing index is [%s] which conflicts with the new
77+
[%s], resetting the attribute to None
6678
"""
67-
class PerformanceWarning(Warning): pass
79+
80+
6881
performance_doc = """
69-
your performance may suffer as PyTables will pickle object types that it cannot map
70-
directly to c-types [inferred_type->%s,key->%s] [items->%s]
82+
your performance may suffer as PyTables will pickle object types that it cannot
83+
map directly to c-types [inferred_type->%s,key->%s] [items->%s]
7184
"""
7285

7386
# map object types

0 commit comments

Comments
 (0)