Skip to content

Commit 9ad2842

Browse files
author
Kevin D Smith
committed
Cleanup for 1.1.0 release
1 parent 6574c00 commit 9ad2842

File tree

14 files changed

+49
-54
lines changed

14 files changed

+49
-54
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11

22
# Change Log
33

4+
## 1.1.0 - 2017-03-21
5+
6+
- Add support for Python 3.6 (Linux extension)
7+
- Implement `sample` method on `CASTable`
8+
- Add sampling support to plotting methods
9+
- `cas.dataset.max_rows_fetched` increased to 10,000
10+
- Add `terminate` method to `CAS` object to end session and close connection
11+
- Implement `fillna`, `replace`, and `dropna` methods on `CASTable`
12+
- Add `apply_labels` method on `SASDataFrame` to set column labels as column names
13+
414
## 1.0.0 - 2016-09-27
515

616
- Initial Release

doc/source/install.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Installation
77
The SWAT package is installed using the ``pip`` command. The requirements
88
for using the binary protocol of CAS (recommended) are as follows.
99

10-
* **64-bit** Python 2.7, 3.4, or 3.5 on Linux (see shared library notes below)
10+
* **64-bit** Python 2.7 or 3.4-3.6 on Linux (see shared library notes below)
1111

1212
The binary protocol requires pre-compiled components found in the ``pip``
1313
installer only. These pieces are not available as source code and

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
setup(
3535
zip_safe = False,
3636
name = 'swat',
37-
version = '1.1.0-dev',
37+
version = '1.1.0',
3838
description = 'SAS Scripting Wrapper for Analytics Transfer (SWAT)',
3939
long_description = README,
4040
author = 'SAS',

swat/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,4 @@
8686
# SAS Formatter
8787
from .formatter import SASFormatter
8888

89-
__version__ = '1.1.0-dev'
89+
__version__ = '1.1.0'

swat/cas/actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def _format_param(param, connection, indent=0, selector=None, path='', output=No
187187
if 'alternatives' in param:
188188
alttypes = list(set([prm['parmType'].replace('value_', '')
189189
for prm in param['alternatives']
190-
if not prm.get('hidden')]))
190+
if not prm.get('hidden')]))
191191
if alttypes == ['list'] and param.get('selector'):
192192
alttypes = ['dict']
193193
for alt in param['alternatives']:

swat/cas/rest/connection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ def _normalize_params(params):
119119

120120

121121
def _normalize_list(items):
122+
''' Normalize objects using standard python types '''
122123
newitems = []
123124
for item in items:
124125
if isinstance(item, dict):

swat/cas/results.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,13 @@
2424
from __future__ import print_function, division, absolute_import, unicode_literals
2525

2626
import collections
27-
import json
2827
import pandas as pd
2928
import pandas.core.common as pdcom
3029
import pprint
3130
import re
3231
import six
33-
from ..config import get_option
3432
from ..dataframe import SASDataFrame, concat
35-
from ..exceptions import SWATError
36-
from ..utils.compat import OrderedDict, items_types
37-
from ..utils import escapejson
33+
from ..utils.compat import OrderedDict
3834
from ..utils.xdict import xadict
3935

4036

@@ -414,11 +410,12 @@ def get_group(_self_, *name, **kwargs):
414410
out = CASResults()
415411

416412
def set_bykey(attrs, bykey=[]):
413+
''' Locate By variable keys '''
417414
if bykey:
418415
return bykey
419416
i = 1
420417
while True:
421-
if ('ByVar%s' % i) not in attrs:
418+
if 'ByVar%s' % i not in attrs:
422419
break
423420
bykey.append(attrs['ByVar%s' % i])
424421
i = i + 1
@@ -514,7 +511,7 @@ def get_tables(self, name, set=None, concat=False, **kwargs):
514511
attrs.pop('ByGroup', None)
515512
attrs.pop('ByGroupIndex', None)
516513
i = 1
517-
while ('ByVar%d' % i) in attrs:
514+
while 'ByVar%d' % i in attrs:
518515
attrs.pop('ByVar%dValue' % i, None)
519516
attrs.pop('ByVar%dValueFormatted' % i, None)
520517
i = i + 1

swat/cas/table.py

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
patch_pandas_sort, char_types, num_types)
4040
from ..utils.keyword import dekeywordify
4141
from .utils.params import ParamManager, ActionParamManager
42-
from .actions import format_params
4342

4443
# pylint: disable=W0212, W0221, W0613, R0904, C0330
4544

@@ -415,7 +414,7 @@ def _get_plot_params(self, x=None, y=None, by=None, **kwargs):
415414
Split parameters into fetch and plot parameter groups
416415
417416
'''
418-
params, kwargs = self._get_sampling_params(**kwargs)
417+
params, kwargs = self._get_sampling_params(**kwargs)
419418
params['grouped'] = True
420419
params['fetchvars'] = self._get_fetchvars(x=x, y=y, by=by)
421420
return params, kwargs
@@ -543,7 +542,7 @@ def density(self, **kwargs):
543542
return self._table._fetch(**params).plot.density(**kwargs)
544543

545544
def hexbin(self, x=None, y=None, C=None, reduce_C_function=None,
546-
gridsize=None, **kwargs):
545+
gridsize=None, **kwargs):
547546
'''
548547
Hexbin plot
549548
@@ -562,8 +561,10 @@ def hexbin(self, x=None, y=None, C=None, reduce_C_function=None,
562561
563562
'''
564563
params, kwargs = self._get_plot_params(x=x, y=y, **kwargs)
565-
return self._table._fetch(**params).plot.hexbin(x=x, y=y, C=C,
566-
reduce_C_function=reduce_C_function, gridsize=gridsize, **kwargs)
564+
return self._table._fetch(**params)\
565+
.plot.hexbin(x=x, y=y, C=C,
566+
reduce_C_function=reduce_C_function,
567+
gridsize=gridsize, **kwargs)
567568

568569
def hist(self, by=None, bins=10, **kwargs):
569570
'''
@@ -1175,9 +1176,6 @@ def _bootstrap(cls, connection):
11751176
11761177
'''
11771178
if not cls.table_params or not cls.outtable_params:
1178-
tblparams = 'Unknown'
1179-
outtblparams = 'Unknown'
1180-
11811179
param_names = []
11821180

11831181
actinfo = connection._get_action_info('builtins.cascommon')
@@ -1187,18 +1185,12 @@ def _bootstrap(cls, connection):
11871185
# Populate valid fields for tables and outtables
11881186
if item['name'] == 'castable':
11891187
cls.table_params = set([x['name'] for x in item['parmList']])
1190-
tblparams = format_params(item['parmList'], connection,
1191-
param_names=param_names).rstrip()
11921188

11931189
elif item['name'] == 'casouttable':
11941190
cls.outtable_params = set([x['name'] for x in item['parmList']])
1195-
outtblparams = format_params(item['parmList'], connection,
1196-
param_names=param_names).rstrip()
11971191

11981192
elif item['name'] == 'casouttablebasic':
11991193
cls.outtable_params = set([x['name'] for x in item['parmList']])
1200-
outtblparams = format_params(item['parmList'], connection,
1201-
param_names=param_names).rstrip()
12021194

12031195
for name in list(param_names):
12041196
if keyword.iskeyword(name):
@@ -3079,8 +3071,8 @@ def describe(self, percentiles=None, include=None, exclude=None, stats=None):
30793071
if not numrows:
30803072
return pd.DataFrame([[0] * len(tbl.columns),
30813073
[0] * len(tbl.columns)],
3082-
index=['count', 'unique'],
3083-
columns=tbl.columns)
3074+
index=['count', 'unique'],
3075+
columns=tbl.columns)
30843076

30853077
# Get percentiles
30863078
if percentiles is not None:
@@ -3277,8 +3269,6 @@ def _topk_values(self, stats=['unique', 'min', 'max'], axis=None, skipna=True,
32773269
:class:`pandas.DataFrame`
32783270
32793271
'''
3280-
from ..dataframe import reshape_bygroups
3281-
32823272
if numeric_only:
32833273
inputs = self._get_dtypes(include='numeric')
32843274
else:
@@ -4008,13 +3998,13 @@ def drop(self, labels, axis=0, level=None, inplace=False, errors='raise'):
40083998
# raise NotImplementedError
40093999

40104000
def reset_index(self, level=None, drop=False, inplace=False,
4011-
col_level=0, col_fill='', **kwargs):
4001+
col_level=0, col_fill='', **kwargs):
40124002
'''
40134003
Reset the CASTable index
40144004
40154005
NOTE: CAS tables do not support indexing, so this method
40164006
just returns self (if inplace=True), or a copy of
4017-
self (if inplace=False) simply for DataFrame
4007+
self (if inplace=False) simply for DataFrame
40184008
compatibility.
40194009
40204010
Returns
@@ -4027,7 +4017,7 @@ def reset_index(self, level=None, drop=False, inplace=False,
40274017
return copy.deepcopy(self)
40284018

40294019
def sample(self, n=None, frac=None, replace=False, weights=None,
4030-
random_state=None, axis=None, stratify_by=None, **kwargs):
4020+
random_state=None, axis=None, stratify_by=None, **kwargs):
40314021
'''
40324022
Returns a random sample of the CAS table rows
40334023
@@ -4368,7 +4358,8 @@ def to_re_sub(patt, to):
43684358
if not isinstance(patt, char_types):
43694359
raise TypeError('Regular expression pattern is not a string: %s' % patt)
43704360
if not isinstance(to, char_types):
4371-
raise TypeError('Regular expression substitution is not a string: %s' % to)
4361+
raise TypeError('Regular expression substitution is not a string: %s'
4362+
% to)
43724363
to = re.sub(r'\\(\d)', r'$\1', to)
43734364
return _quote('s/%s/%s/%s' % (patt, to, flags))
43744365

@@ -4464,7 +4455,8 @@ def _apply_datastep(self, code, inplace=False, casout=None):
44644455

44654456
dscode = []
44664457
dscode.append('data %s(caslib=%s);' % (_quote(newname), _quote(caslib)))
4467-
dscode.append(' set %s(caslib=%s);' % (_quote(self.params.name), _quote(caslib)))
4458+
dscode.append(' set %s(caslib=%s);' % (_quote(self.params.name),
4459+
_quote(caslib)))
44684460
if isinstance(code, items_types):
44694461
dscode.extend(code)
44704462
else:
@@ -4650,7 +4642,7 @@ def to_view(self, *args, **kwargs):
46504642
# raise NotImplementedError
46514643

46524644
def _fetch(self, grouped=False, sample_pct=None, sample_seed=None,
4653-
stratify_by=None, sample=False, **kwargs):
4645+
stratify_by=None, sample=False, **kwargs):
46544646
'''
46554647
Return the fetched DataFrame given the fetch parameters
46564648
@@ -4710,7 +4702,7 @@ def _fetch(self, grouped=False, sample_pct=None, sample_seed=None,
47104702

47114703
# Add grouping columns if they aren't in the list
47124704
columns = None
4713-
if groups and 'fetchvars' in kwargs:
4705+
if groups and 'fetchvars' in kwargs:
47144706
kwargs['fetchvars'] = list(kwargs['fetchvars'])
47154707
for group in reversed(groups):
47164708
if group not in kwargs['fetchvars']:
@@ -4724,7 +4716,8 @@ def _fetch(self, grouped=False, sample_pct=None, sample_seed=None,
47244716

47254717
# Sort based on 'Fetch#' key. This will be out of order in REST.
47264718
values = [x[1] for x in sorted(tbl._retrieve('table.fetch', **kwargs).items(),
4727-
key=lambda x: int(x[0].replace('Fetch', '') or '0'))]
4719+
key=lambda x: int(x[0].replace('Fetch', '') or
4720+
'0'))]
47284721
out = df.concat(values)
47294722

47304723
if tbl is not self:
@@ -4786,7 +4779,7 @@ def _sample(self, sample_pct=None, sample_seed=None, stratify_by=None, columns=N
47864779
return out
47874780

47884781
def _fetchall(self, grouped=False, sample_pct=None, sample_seed=None,
4789-
sample=False, stratify_by=None, **kwargs):
4782+
sample=False, stratify_by=None, **kwargs):
47904783
''' Fetch all rows '''
47914784
kwargs = kwargs.copy()
47924785
if 'to' not in kwargs:
@@ -4940,7 +4933,7 @@ def _from_any(cls, name, connection, data, **kwargs):
49404933
if 'table' in table:
49414934
table['name'] = table.pop('table')
49424935
return connection.upload_frame(dframe, casout=table and table or None)
4943-
# importoptions=connection._importoptions_from_dframe(dframe)
4936+
# importoptions=connection._importoptions_from_dframe(dframe)
49444937
dmh = PandasDataFrame(dframe)
49454938
table.update(dmh.args.addtable)
49464939
return connection.retrieve('table.addtable', **table)['casTable']
@@ -5129,7 +5122,7 @@ def info(self, verbose=None, buf=None, max_cols=None,
51295122
buf.write(u'memory usage: %s\n' % details['AllocatedMemory'])
51305123

51315124
def to_frame(self, sample_pct=None, sample_seed=None, sample=False,
5132-
stratify_by=None, **kwargs):
5125+
stratify_by=None, **kwargs):
51335126
'''
51345127
Retrieve entire table as a :class:`SASDataFrame`
51355128
@@ -5175,7 +5168,7 @@ def _to_any(self, method, *args, **kwargs):
51755168
params['stratify_by'] = kwargs.pop('stratify_by', None)
51765169
params['to'] = kwargs.pop('to', None)
51775170
params['from'] = kwargs.pop('from', kwargs.pop('from_', None))
5178-
params = {k:v for k, v in params.items() if v is not None}
5171+
params = {k: v for k, v in params.items() if v is not None}
51795172
standard_dataframe = kwargs.pop('standard_dataframe', False)
51805173
dframe = self._fetch(**params)
51815174
if standard_dataframe:
@@ -7574,7 +7567,7 @@ def _compute(self, funcname, code, use_quotes=True, extra_computedvars=None,
75747567
if eval_values and isinstance(item, (CASColumn, pd.Series)):
75757568
for subitem in item.unique().tolist():
75767569
if isinstance(subitem, text_types) or \
7577-
isinstance(subitem, binary_types):
7570+
isinstance(subitem, binary_types):
75787571
items.append('"%s"' % _escape_string(subitem))
75797572
else:
75807573
items.append(str(subitem))

swat/cas/transformers.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424
from __future__ import print_function, division, absolute_import, unicode_literals
2525

2626
import base64
27-
import collections
2827
import datetime
2928
import numpy as np
3029
import pandas as pd
31-
import re
3230
import six
3331
from .utils import datetime as casdt
3432
from .. import clib

swat/cas/utils/datetime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
from __future__ import print_function, division, absolute_import, unicode_literals
2525

2626
import datetime
27+
import numpy as np
2728
import pandas as pd
28-
import six
2929
import time
3030
from ...utils.compat import int64, int32
3131

0 commit comments

Comments
 (0)