Skip to content

Commit

Permalink
style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
christinafan committed Jun 26, 2023
1 parent 035084c commit dfa7905
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 111 deletions.
44 changes: 3 additions & 41 deletions modin/core/dataframe/pandas/dataframe/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2024,9 +2024,7 @@ def window_function_complete(virtual_partition):
def window_function_partition(virtual_partition):

virtual_partition_copy = virtual_partition.copy()
#print(virtual_partition_copy.to_pandas())
window_result = reduce_fn(virtual_partition_copy)
#breakpoint()
return window_result.iloc[:, window_size - 1 : ] if axis == Axis.COL_WISE else window_result.iloc[window_size - 1: , :]

num_parts = len(self._partitions[0]) if axis == Axis.COL_WISE else len(self._partitions)
Expand All @@ -2037,10 +2035,7 @@ def window_function_partition(virtual_partition):
starting_part = self._partitions[:, [i]] if axis == Axis.COL_WISE else self._partitions[i]

# partitions to join in virtual partition
parts_to_join = [starting_part] if (axis == Axis.ROW_WISE) else [[partition[0]] for partition in starting_part]

#for part in parts_to_join:
#print(part.to_pandas())
parts_to_join = [starting_part] if (axis == Axis.ROW_WISE) else [[partition[0]] for partition in starting_part]

last_window_span = window_size - 1

Expand All @@ -2056,12 +2051,9 @@ def window_function_partition(virtual_partition):
masked_new_parts = [[part[0].mask(row_labels = slice(None), col_labels = slice(0, last_window_span))] for part in new_parts]
for x, r in enumerate(parts_to_join):
r.append(masked_new_parts[x][0])
#print(masked_new_parts[x][0].to_pandas())
else:
masked_new_parts = np.array([part.mask(row_labels = slice(0, last_window_span), col_labels=slice(None)) for part in new_parts])
parts_to_join.append(masked_new_parts)
#for part in masked_new_parts:
#print(part.to_pandas())
break
else:
# window continues into next part, so just add this part to parts_to_join
Expand All @@ -2071,21 +2063,15 @@ def window_function_partition(virtual_partition):
else:
parts_to_join.append(new_parts)
last_window_span -= part_len
k += 1

#for part in parts_to_join:
#print(part.to_pandas())
k += 1

# create virtual partition and perform window operation
virtual_partitions = self._partition_mgr_cls.row_partitions(np.array(parts_to_join), full_axis = False) if axis == Axis.COL_WISE else self._partition_mgr_cls.column_partitions(np.array(parts_to_join), full_axis=False)

if i == 0:
reduce_result = [virtual_partition.apply(window_function_complete) for virtual_partition in virtual_partitions]
else:
reduce_result = [virtual_partition.apply(window_function_partition) for virtual_partition in virtual_partitions]

#for result in reduce_result:
#print(result.to_pandas())
reduce_result = [virtual_partition.apply(window_function_partition) for virtual_partition in virtual_partitions]

if axis == Axis.ROW_WISE:
results.append(reduce_result)
Expand All @@ -2105,31 +2091,7 @@ def window_function_partition(virtual_partition):
None,
None,
result_schema
)

"""
# NAIVE VERSION
# axis could also be passed in as an integer, so convert to Axis enum so that axis var
# is always an enum in our code
axis = Axis(axis)
def window_function(df):
return df.rolling(window=window_size, axis=axis.value).sum() # hardcode a reduction function for now
# need to pass in axis.value instead of just axis because map_axis_partitions takes in an integer
new_partitions = self._partition_mgr_cls.map_axis_partitions(
axis.value, self._partitions, window_function
)
return self.__constructor__(
new_partitions,
self.index,
self.columns,
self._row_lengths,
self._column_widths,
result_schema
)
"""


@lazy_metadata_decorator(apply_axis="both")
Expand Down
Loading

0 comments on commit dfa7905

Please sign in to comment.