Skip to content

Commit f89b491

Browse files
committed
REF: promote parser.pyx into top level
1 parent 3db8947 commit f89b491

File tree

6 files changed

+32
-32
lines changed

6 files changed

+32
-32
lines changed

pandas/io/parsers.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import pandas.lib as lib
2222
import pandas.tslib as tslib
23-
import pandas._parser as _parser
23+
import pandas.parser as _parser
2424
from pandas.tseries.period import Period
2525
import json
2626

@@ -752,7 +752,7 @@ def __init__(self, kwds):
752752
[ com.is_integer(i) for i in self.index_col ]) or com.is_integer(self.index_col)):
753753
raise Exception("index_col must only contain row numbers "
754754
"when specifying a multi-index header")
755-
755+
756756
self._name_processed = False
757757

758758
@property
@@ -783,7 +783,7 @@ def _extract_multi_indexer_columns(self, header, index_names, col_names, passed_
783783

784784
# the names are the tuples of the header that are not the index cols
785785
# 0 is the name of the index, assuming index_col is a list of column
786-
# numbers
786+
# numbers
787787
ic = self.index_col
788788
if ic is None:
789789
ic = []
@@ -795,8 +795,8 @@ def _extract_multi_indexer_columns(self, header, index_names, col_names, passed_
795795
orig_header = list(header)
796796

797797
# clean the index_names
798-
index_names = header.pop(-1)
799-
(index_names, names,
798+
index_names = header.pop(-1)
799+
(index_names, names,
800800
index_col) = _clean_index_names(index_names, self.index_col)
801801

802802
# extract the columns
@@ -846,7 +846,7 @@ def _make_index(self, data, alldata, columns, indexnamerow=False):
846846
index = self._get_complex_date_index(data, columns)
847847
index = self._agg_index(index, try_parse_dates=False)
848848

849-
# add names for the index
849+
# add names for the index
850850
if indexnamerow:
851851
coffset = len(indexnamerow) - len(columns)
852852
index.names = indexnamerow[:coffset]
@@ -1060,7 +1060,7 @@ def __init__(self, src, **kwds):
10601060
_is_index_col(self.index_col)):
10611061

10621062
self._name_processed = True
1063-
(index_names, self.names,
1063+
(index_names, self.names,
10641064
self.index_col) = _clean_index_names(self.names, self.index_col)
10651065

10661066
if self.index_names is None:
@@ -1498,7 +1498,7 @@ def _infer_columns(self):
14981498
if cur_count > 0:
14991499
this_columns[i] = '%s.%d' % (col, cur_count)
15001500
counts[col] = cur_count + 1
1501-
1501+
15021502
columns.append(this_columns)
15031503

15041504
self._clear_buffer()
@@ -1993,5 +1993,3 @@ def __init__(self, path_or_buf, kind=None, **kwds):
19931993
from warnings import warn
19941994
warn("ExcelFile can now be imported from: pandas.io.excel", FutureWarning)
19951995
super(ExcelFile, self).__init__(path_or_buf, kind=kind, **kwds)
1996-
1997-

pandas/io/tests/test_cparser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
import pandas.util.testing as tm
2929

30-
from pandas._parser import TextReader
31-
import pandas._parser as parser
30+
from pandas.parser import TextReader
31+
import pandas.parser as parser
3232

3333

3434
class TestCParser(unittest.TestCase):

pandas/io/tests/test_html.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
from pandas.io.html import _BeautifulSoupHtml5LibFrameParser
1818
from pandas.io.html import _BeautifulSoupLxmlFrameParser, _remove_whitespace
1919
from pandas import DataFrame, MultiIndex, read_csv, Timestamp
20-
from pandas.util.testing import assert_frame_equal, network, get_data_path
20+
from pandas.util.testing import (assert_frame_equal, network,
21+
get_data_path)
22+
from numpy.testing.decorators import slow
23+
2124
from pandas.util.testing import makeCustomDataframe as mkdf
2225

2326

@@ -93,6 +96,7 @@ def run_read_html(self, *args, **kwargs):
9396
return _run_read_html(parser, *args, **kwargs)
9497

9598
@network
99+
@slow
96100
def test_banklist_url(self):
97101
url = 'http://www.fdic.gov/bank/individual/failed/banklist.html'
98102
df1 = self.run_read_html(url, 'First Federal Bank of Florida',
@@ -102,6 +106,7 @@ def test_banklist_url(self):
102106
assert_framelist_equal(df1, df2)
103107

104108
@network
109+
@slow
105110
def test_spam_url(self):
106111
url = ('http://ndb.nal.usda.gov/ndb/foods/show/1732?fg=&man=&'
107112
'lfacet=&format=&count=&max=25&offset=&sort=&qlookup=spam')
@@ -361,6 +366,7 @@ def test_multiple_matches(self):
361366
self.assertGreater(len(dfs), 1)
362367

363368
@network
369+
@slow
364370
def test_pythonxy_plugins_table(self):
365371
url = 'http://code.google.com/p/pythonxy/wiki/StandardPlugins'
366372
dfs = self.run_read_html(url, match='Python',

pandas/io/tests/test_parsers.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
from numpy.testing.decorators import slow
3636

37-
from pandas._parser import OverflowError
37+
from pandas.parser import OverflowError
3838

3939

4040
class ParserTests(object):
@@ -536,7 +536,7 @@ def test_nat_parse(self):
536536

537537
# GH 3062
538538
df = DataFrame(dict({
539-
'A' : np.asarray(range(10),dtype='float64'),
539+
'A' : np.asarray(range(10),dtype='float64'),
540540
'B' : pd.Timestamp('20010101') }))
541541
df.iloc[3:6,:] = np.nan
542542

@@ -1025,19 +1025,19 @@ def test_header_multi_index(self):
10251025
#### invalid options ####
10261026

10271027
# no as_recarray
1028-
self.assertRaises(Exception, read_csv, StringIO(data), header=[0,1,2,3],
1028+
self.assertRaises(Exception, read_csv, StringIO(data), header=[0,1,2,3],
10291029
index_col=[0,1], as_recarray=True, tupleize_cols=False)
10301030

10311031
# names
1032-
self.assertRaises(Exception, read_csv, StringIO(data), header=[0,1,2,3],
1032+
self.assertRaises(Exception, read_csv, StringIO(data), header=[0,1,2,3],
10331033
index_col=[0,1], names=['foo','bar'], tupleize_cols=False)
10341034
# usecols
1035-
self.assertRaises(Exception, read_csv, StringIO(data), header=[0,1,2,3],
1035+
self.assertRaises(Exception, read_csv, StringIO(data), header=[0,1,2,3],
10361036
index_col=[0,1], usecols=['foo','bar'], tupleize_cols=False)
10371037
# non-numeric index_col
1038-
self.assertRaises(Exception, read_csv, StringIO(data), header=[0,1,2,3],
1038+
self.assertRaises(Exception, read_csv, StringIO(data), header=[0,1,2,3],
10391039
index_col=['foo','bar'], tupleize_cols=False)
1040-
1040+
10411041
def test_pass_names_with_index(self):
10421042
lines = self.data1.split('\n')
10431043
no_header = '\n'.join(lines[1:])
File renamed without changes.

setup.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ class CheckSDist(sdist):
286286
'pandas/tslib.pyx',
287287
'pandas/index.pyx',
288288
'pandas/algos.pyx',
289-
'pandas/src/parser.pyx',
289+
'pandas/parser.pyx',
290290
'pandas/src/sparse.pyx']
291291

292292
def initialize_options(self):
@@ -412,6 +412,12 @@ def pxd(name):
412412
'pandas/src/datetime/np_datetime_strings.c']},
413413
algos={'pyxfile': 'algos',
414414
'depends': [srcpath('generated', suffix='.pyx')]},
415+
parser=dict(pyxfile='parser',
416+
depends=['pandas/src/parser/tokenizer.h',
417+
'pandas/src/parser/io.h',
418+
'pandas/src/numpy_helper.h'],
419+
sources=['pandas/src/parser/tokenizer.c',
420+
'pandas/src/parser/io.c'])
415421
)
416422

417423
extensions = []
@@ -440,16 +446,6 @@ def pxd(name):
440446
libraries=libraries)
441447

442448

443-
parser_ext = Extension('pandas._parser',
444-
depends=['pandas/src/parser/tokenizer.h',
445-
'pandas/src/parser/io.h',
446-
'pandas/src/numpy_helper.h'],
447-
sources=[srcpath('parser', suffix=suffix),
448-
'pandas/src/parser/tokenizer.c',
449-
'pandas/src/parser/io.c',
450-
],
451-
include_dirs=common_include)
452-
453449
sandbox_ext = Extension('pandas._sandbox',
454450
sources=[srcpath('sandbox', suffix=suffix)],
455451
include_dirs=common_include)
@@ -460,7 +456,7 @@ def pxd(name):
460456
sources=[srcpath('cppsandbox', suffix=suffix)],
461457
include_dirs=[])
462458

463-
extensions.extend([sparse_ext, parser_ext])
459+
extensions.extend([sparse_ext])
464460

465461
# if not ISRELEASED:
466462
# extensions.extend([sandbox_ext])

0 commit comments

Comments
 (0)