Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
slobodan-ilic committed Feb 1, 2018
1 parent f119cd8 commit 3836464
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
3 changes: 0 additions & 3 deletions src/cr/cube/crunch_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,8 @@ def _transform(self, res, include_transforms_for_dims, valid_indices):
ind_insertion = indices['anchor_ind'] + ind_offset
if i == 0:
value = sum(res[ind_subtotal_elements])
# res = np.insert(res, ind_insertion + 1, value, axis=i)
else:
value = np.sum(res[:, ind_subtotal_elements], axis=1)
# res = np.insert(res, ind_insertion + 1, value, axis=i)
insertions.append((ind_insertion, value))

for j, (ind_insertion, value) in enumerate(insertions):
Expand Down Expand Up @@ -548,7 +546,6 @@ def _inflate_dim(self, array, axis):

def _margin(self, axis=None, weighted=True, adjusted=False,
include_transforms_for_dims=None, prune=False):
'''Calculate cube margin.'''

# MR margins are calculated differently, so they need a separate method
# for them. A good example of this is the rcrunch functionality.
Expand Down
25 changes: 10 additions & 15 deletions src/cr/cube/dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,17 @@ def _elements(self):
@property
def hs_indices(self):
'''Headers and Subtotals indices.'''
elms = self._elements

indices = [{
'anchor_ind': [
i
for (i, el) in enumerate(self._elements)
if el['id'] == subtotal.anchor
][0]
if (subtotal.anchor in [el['id'] for el in self._elements]) else
subtotal.anchor,
# -1,
'inds': [
i
for (i, el) in enumerate(self._elements)
if el['id'] in subtotal.args
],
} for subtotal in self.subtotals]
'anchor_ind': (
[i for (i, el) in enumerate(elms) if el['id'] == st.anchor][0]
if (st.anchor in [el['id'] for el in elms]) else
st.anchor
),
'inds': [i for (i, el) in enumerate(elms) if el['id'] in st.args],
} for st in self.subtotals]

return indices

@property
Expand Down Expand Up @@ -179,7 +175,6 @@ def labels(self, include_missing=False, include_transforms=False,
ind_insert = next((
i for (i, x) in enumerate(labels_with_cat_ids)
if x.get('id') == subtotal.anchor
# ), -1) + 1
), subtotal.anchor)
if ind_insert == 'top':
ind_insert = 0
Expand Down

0 comments on commit 3836464

Please sign in to comment.