Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self,
filename="output",
concurrency=1, mpi_size=1,
timemory_functions=[],
title="",
units="",
ctype="",
description="",
plot_params=plot_parameters(),
output_name=None):
def _convert(_obj):
if isinstance(_obj, dict):
_ret = []
for key, item in _obj.items():
_ret.append(item)
return _ret
else:
return _obj
self.units = _convert(units)
self.ctype = _convert(ctype)
self.description = _convert(description)
self.nitems = 1
def read(json_obj, plot_params=plot_parameters()):
"""
Read the JSON data -- i.e. process JSON object of TiMemory data
"""
# some fields
data0 = json_obj
nranks = len(data0['ranks']) if 'ranks' in data0 else 1
concurrency_sum = 0
timemory_functions = nested_dict()
print('num ranks = {}'.format(nranks))
data1 = data0['rank']
nthrd = data1['concurrency'] # concurrency
rdata = data1['data'] # rank data
ctype = rdata['type'] # collection type
def plot(data=[], files=[], plot_params=plot_parameters(),
combine=False, display=False, output_dir='.', echo_dart=None):
"""
A function to plot JSON data
Args:
- data (list):
- list of "plot_data" objects
- should contain their own plot_parameters object
- files (list):
- list of JSON files
- "plot_params" argument object will be applied to these files
- combine (bool):
- if specified, the plot_data objects from "data" and "files"
will be combined into one "plot_data" object
- the plot_params object will be used for this
"""
def echo_dart_tag(name, filepath, img_type=plot_parameters.img_type):
"""
Printing this string will upload the results to CDash when running CTest
"""
print('{}'.format(img_type, filepath))
def plot_maximums(output_name, title, data, plot_params=plot_parameters(),
display=False, output_dir='.', echo_dart=None):
"""
A function to plot JSON data
Args:
- data (list):
- list of "plot_data" objects
- should contain their own plot_parameters object
- files (list):
- list of JSON files
- "plot_params" argument object will be applied to these files
- combine (bool):
- if specified, the plot_data objects from "data" and "files"
will be combined into one "plot_data" object
- the plot_params object will be used for this
"""