Skip to content

Commit

Permalink
refactor: flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
keyanyang committed May 1, 2020
1 parent f9aa764 commit b875301
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions mlxtend/frequent_patterns/apriori.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ def _support(_x, _n_rows, _is_sparse):
res_df.columns = ['support', 'itemsets']
if use_colnames:
mapping = {idx: item for idx, item in enumerate(df.columns)}
res_df['itemsets'] = [frozenset(a) for a in np.vectorize(map)\
(mapping.get, res_df['itemsets'])]
res_df['itemsets'] = [frozenset(a) for a in np.vectorize(map)(
mapping.get, res_df['itemsets'])]
res_df = res_df.reset_index(drop=True)

if verbose:
Expand Down
4 changes: 2 additions & 2 deletions mlxtend/frequent_patterns/fpcommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def generate_itemsets(generator, num_itemsets, colname_map):
res_df = pd.DataFrame({'support': supports, 'itemsets': itemsets})

if colname_map is not None:
res_df['itemsets'] = [frozenset(a) for a in np.vectorize(map)\
(colname_map.get, res_df['itemsets'])]
res_df['itemsets'] = [frozenset(a) for a in np.vectorize(map)(
colname_map.get, res_df['itemsets'])]
return res_df


Expand Down
12 changes: 6 additions & 6 deletions mlxtend/frequent_patterns/tests/test_association_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ def test_default():
columns=columns_ordered
)

expect['antecedents'] = np.vectorize(str)\
(np.vectorize(frozenset)(expect['antecedents']))
expect['consequents'] = np.vectorize(str)\
(np.vectorize(frozenset)(expect['consequents']))
expect['antecedents'] = np.vectorize(str)(
np.vectorize(frozenset)(expect['antecedents']))
expect['consequents'] = np.vectorize(str)(
np.vectorize(frozenset)(expect['consequents']))
expect.sort_values(columns_ordered, inplace=True)
expect.reset_index(inplace=True, drop=True)

Expand All @@ -66,8 +66,8 @@ def test_datatypes():
# check if association_rule converts it internally
# back to frozensets
df_freq_items_copy = df_freq_items.copy()
df_freq_items_copy['itemsets'] = np.vectorize(set)\
(df_freq_items_copy['itemsets'])
df_freq_items_copy['itemsets'] = np.vectorize(set)(
df_freq_items_copy['itemsets'])

res_df = association_rules(df_freq_items)
for i in res_df['antecedents']:
Expand Down

0 comments on commit b875301

Please sign in to comment.