Commit aa675975 authored by Sanjay Yadav's avatar Sanjay Yadav

ENH: Fixed replication issue.

parent 0a35cb68
Pipeline #31553 failed with stage
in 52 seconds
......@@ -132,8 +132,7 @@ def pptgen(source, target, **config):
# Restrict to specific slides, if specified
if not is_slide_allowed(change, slide, index + 1):
continue
if 'replicate' in change and change['replicate'] is not None:
if change.get('replicate'):
is_grp = isinstance(slide_data, pd.core.groupby.DataFrameGroupBy)
if isinstance(slide_data, collections.Iterable):
for _slide_data in slide_data:
......@@ -199,7 +198,7 @@ def change_shapes(collection, change, data, **kwargs):
mapping[shape.name] = 0
handler = data.pop('handler') if 'handler' in data else None
if 'data' in spec and spec['data'] is not None:
if spec.get('data'):
if not isinstance(spec['data'], (dict,)):
spec['data'] = {'function': '{}'.format(spec['data']) if not isinstance(
spec['data'], (str, six.string_types,)) else spec['data']}
......@@ -210,7 +209,7 @@ def change_shapes(collection, change, data, **kwargs):
if isinstance(shape_data, (dict, AttrDict,)):
shape_data['handler'] = handler
if 'stack' in spec and spec.get('stack') is not None:
if spec.get('stack'):
shape_data = shape_data[mapping[shape.name]]
mapping[shape.name] = mapping[shape.name] + 1
......
......@@ -322,7 +322,7 @@ def table(shape, spec, data):
"""Update an existing Table shape with data."""
if not spec.get('table', {}).get('data'):
return
spec = spec['table']
spec = copy.deepcopy(spec['table'])
handler = data.pop('handler') if 'handler' in data else None
data = compile_function(spec, 'data', data, handler)
if not len(data):
......@@ -403,7 +403,7 @@ def chart(shape, spec, data):
if not chart_type:
raise NotImplementedError()
info = spec['chart']
info = copy.deepcopy(spec['chart'])
# Load data
handler = data.pop('handler') if 'handler' in data else None
if isinstance(info['x'], (dict,)):
......@@ -481,7 +481,7 @@ def sankey(shape, spec, data):
# Getting parent shapes
pxl_to_inch = 10000
default_thickness = 40
spec = spec['sankey']
spec = copy.deepcopy(spec['sankey'])
handler = data.pop('handler') if 'handler' in data else None
shapes = shape._parent
......@@ -585,7 +585,7 @@ def treemap(shape, spec, data):
y0 = shape.top
width = shape.width
height = shape.height
spec = spec['treemap']
spec = copy.deepcopy(spec['treemap'])
stroke = spec.get('stroke', '#ffffff')
# Load data
handler = data.pop('handler') if 'handler' in data else None
......@@ -629,7 +629,7 @@ def calendarmap(shape, spec, data):
raise NotImplementedError()
shapes = shape._parent
spec = spec['calendarmap']
spec = copy.deepcopy(spec['calendarmap'])
handler = data.get('handler')
# Load data
data = compile_function(spec, 'data', data, handler)
......@@ -757,7 +757,7 @@ def bullet(shape, spec, data):
"""Function to plot bullet chart."""
if shape.auto_shape_type != MSO_SHAPE.RECTANGLE:
raise NotImplementedError()
spec = spec['bullet']
spec = copy.deepcopy(spec['bullet'])
orient = spec.get('orient', 'horizontal')
if orient not in {'horizontal', 'vertical'}:
raise NotImplementedError()
......@@ -768,12 +768,8 @@ def bullet(shape, spec, data):
height = shape.height if orient == 'horizontal' else shape.width
width = shape.width if orient == 'horizontal' else shape.height
handler = data.get('handler')
for metric in ['poor', 'average', 'good', 'target']:
if metric in spec:
spec[metric] = compile_function(spec, metric, data, handler)
else:
spec[metric] = np.nan
for met in ['poor', 'average', 'good', 'target']:
spec[met] = compile_function(spec, met, data, handler) if spec.get(met) else np.nan
if text:
text = compile_function({'text': spec['text']}, 'text', data, handler)
......@@ -850,7 +846,7 @@ def bullet(shape, spec, data):
def rectangle(shape, spec, data):
"""Function to modify a rectangle's property in PPT."""
pxl_to_inch = 10000
spec = spec['rectangle']
spec = copy.deepcopy(spec['rectangle'])
handler = data.pop('handler') if 'handler' in data else None
data = compile_function(spec, 'data', data, handler)
......@@ -882,7 +878,7 @@ def custom_table(shape, spec, data):
"""Update an existing Table shape with data."""
if not spec.get('custom_table', {}).get('data'):
return
spec = spec['custom_table']
spec = copy.deepcopy(spec['custom_table'])
handler = data.pop('handler') if 'handler' in data else None
data = compile_function(spec, 'data', data, handler)
if not len(data):
......@@ -1048,7 +1044,7 @@ def bar_circle(shape, spec, data):
def heatgrid(shape, spec, data):
"""Create a heat grid."""
spec = spec['heatgrid']
spec = copy.deepcopy(spec['heatgrid'])
top = shape.top
left = shape.left
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment