# Path: examples/lowRankTensorApproximations/fig_pars.py
# def set_labels():
#     lines={'Gafull': 'bo-',
#            'GaNifull': '--',
#            'Gacano': 'bx-',
#            'Gatucker': 'ro-',
#            'Gatt': 'kv-',
# 
#            'GaSparse': 'rx-',
#            'GaSparse_2': 'ro-',
#            'GaSparse_3': 'r<-',
#            'GaSparse_4': 'r*-',
#            'GaSparse_5': 'rd-',
#            'GaSparse_6': 'rv-',
#            'GaSparse_7': 'r^-',
# 
#            'full': '--',
#            'mem_cano':   ['bx--','bo--','bx--','bv--','bo--','bx--','b<--'],
#            'mem_tucker': ['rx--', 'ro--', 'rx--', 'rv--', 'ro--', 'rx--', 'r<--'],
#            'mem_tt':     ['kx-', 'ko-', 'kx--', 'kv--', 'ko--', 'kx--', 'k<--'],
# 
#            'Ga_cano': ['bx-', 'bo-', 'bx-', 'bv-', 'bo-', 'bx-', 'b<-'],
#            'Ga_tucker': ['rx-', 'ro-', 'rx-', 'rv-', 'ro-', 'rx-', 'r<-'],
#            'Ga_tt': ['kx-', 'ko-','kx--', 'kv-', 'ko-', 'kx-', 'k<-'],
# 
#            'GaNi_cano': ['bx--', 'bo--', 'bx--', 'bv--', 'bo--', 'bx--', 'b<--'],
#            'GaNi_tucker': ['rx--', 'ro--', 'rx--', 'rv--', 'ro--', 'rx--', 'r<--'],
#            'GaNi_tt': ['kx--', 'ko--', 'kx--', 'kv--', 'ko--', 'kx--', 'k<--'],
# 
# 
#            'Ga': ['-','x-','<-','|-','^-','x-','o-', '<-', 'v-','^-','d-',],
#            'GaNi': ['--', 'x--', '<--', '|--', '^--', 'x--', 'o--', '<--', 'v--', '^--', 'd--'],
# 
#            }
# 
#     labels = {'full': 'Full',
#               'tensorsLowRank': 'Sparse',
#               'Gafull': 'Ga Full',
#               'Gacano': 'Ga CP',
#               'Gatucker': 'Ga Tucker',
#               'Gatt': 'Ga TT',
# 
#               'Garank': 'Solution rank',
#               'GaNirank': 'Solution rank',
# 
#               'GaNifull': 'GaNi Full',
# 
#               'GaNicano': 'GaNi CP',
#               'GaNicanoN': 'Cano N=',
# 
#               'GaNitucker': 'GaNi Tucker',
#               'GaNituckerN': 'Tucker N=',
# 
#               'GaNitt': 'GaNi TT',
#               'GaNittN': 'TT N=',
#               }
#     return lines, labels
# 
# def set_pars(mpl):
#     mpl.rcParams['text.latex.preamble'] = [r"\usepackage{amsmath,bm,amsfonts}"]
#     params={'text.usetex': True,
#             'font.family': 'serif',
#             'font.size': 12,
#             'legend.fontsize': 10,
#             }
#     mpl.rcParams.update(params)
#     fig_par={'dpi': 1000,
#              'facecolor': 'w',
#              'edgecolor': 'k',
#              'figsize': (4, 3),
#              'figsize3D': (4, 4),
#              'pad_inches': 0.02,
#              }
# 
#     return fig_par


import pickle
import matplotlib as mpl
import matplotlib.pyplot as plt
import os
from examples.lowRankTensorApproximations.fig_pars import set_labels, set_pars

                    for sol_rank in range(0, len(
                            sol_rank_range)):
                        plt.semilogy(list(range(len(res_Ga_Spar[sol_rank]))), res_Ga_Spar[sol_rank],
                                     lines['Ga'][sol_rank],
                                     label='{} {}'.format(labels['Garank'], sol_rank_range[sol_rank]),
                                     markevery=2)

                    ax = plt.gca()
                    plt.xticks(iter_rank_range_set)
                    plt.xlabel(xlabel)
                    ax.set_xlim(xlimit)

                    plt.ylabel(ylabel)
                    ax.set_ylim(ylimit)

                    plt.legend(loc='best')
                    fname = src + 'Residuum_dim{}_mat{}_kind_{}_Ga_{}_N{}{}'.format(dim, material, kind_list[kind],
                                                                                    solver, N, '.pdf')
                    print(('create figure: {}'.format(fname)))
                    plt.savefig(fname, dpi=parf['dpi'], pad_inches=parf['pad_inches'],
                                bbox_inches='tight')
            print('END Ga 3D residuum N={} mat {}'.format(N, material))
            ##### END: figure 5.1 Residuum for Ga solution ###########

            ##### BEGIN: figure 5.2 Residuum for GaNi solution ###########
            for material in material_list:
                for kind in kinds['{}'.format(dim)]:

                    parf = set_pars(mpl)

# Path: examples/lowRankTensorApproximations/fig_pars.py
# def set_labels():
#     lines={'Gafull': 'bo-',
#            'GaNifull': '--',
#            'Gacano': 'bx-',
#            'Gatucker': 'ro-',
#            'Gatt': 'kv-',
# 
#            'GaSparse': 'rx-',
#            'GaSparse_2': 'ro-',
#            'GaSparse_3': 'r<-',
#            'GaSparse_4': 'r*-',
#            'GaSparse_5': 'rd-',
#            'GaSparse_6': 'rv-',
#            'GaSparse_7': 'r^-',
# 
#            'full': '--',
#            'mem_cano':   ['bx--','bo--','bx--','bv--','bo--','bx--','b<--'],
#            'mem_tucker': ['rx--', 'ro--', 'rx--', 'rv--', 'ro--', 'rx--', 'r<--'],
#            'mem_tt':     ['kx-', 'ko-', 'kx--', 'kv--', 'ko--', 'kx--', 'k<--'],
# 
#            'Ga_cano': ['bx-', 'bo-', 'bx-', 'bv-', 'bo-', 'bx-', 'b<-'],
#            'Ga_tucker': ['rx-', 'ro-', 'rx-', 'rv-', 'ro-', 'rx-', 'r<-'],
#            'Ga_tt': ['kx-', 'ko-','kx--', 'kv-', 'ko-', 'kx-', 'k<-'],
# 
#            'GaNi_cano': ['bx--', 'bo--', 'bx--', 'bv--', 'bo--', 'bx--', 'b<--'],
#            'GaNi_tucker': ['rx--', 'ro--', 'rx--', 'rv--', 'ro--', 'rx--', 'r<--'],
#            'GaNi_tt': ['kx--', 'ko--', 'kx--', 'kv--', 'ko--', 'kx--', 'k<--'],
# 
# 
#            'Ga': ['-','x-','<-','|-','^-','x-','o-', '<-', 'v-','^-','d-',],
#            'GaNi': ['--', 'x--', '<--', '|--', '^--', 'x--', 'o--', '<--', 'v--', '^--', 'd--'],
# 
#            }
# 
#     labels = {'full': 'Full',
#               'tensorsLowRank': 'Sparse',
#               'Gafull': 'Ga Full',
#               'Gacano': 'Ga CP',
#               'Gatucker': 'Ga Tucker',
#               'Gatt': 'Ga TT',
# 
#               'Garank': 'Solution rank',
#               'GaNirank': 'Solution rank',
# 
#               'GaNifull': 'GaNi Full',
# 
#               'GaNicano': 'GaNi CP',
#               'GaNicanoN': 'Cano N=',
# 
#               'GaNitucker': 'GaNi Tucker',
#               'GaNituckerN': 'Tucker N=',
# 
#               'GaNitt': 'GaNi TT',
#               'GaNittN': 'TT N=',
#               }
#     return lines, labels
# 
# def set_pars(mpl):
#     mpl.rcParams['text.latex.preamble'] = [r"\usepackage{amsmath,bm,amsfonts}"]
#     params={'text.usetex': True,
#             'font.family': 'serif',
#             'font.size': 12,
#             'legend.fontsize': 10,
#             }
#     mpl.rcParams.update(params)
#     fig_par={'dpi': 1000,
#              'facecolor': 'w',
#              'edgecolor': 'k',
#              'figsize': (4, 3),
#              'figsize3D': (4, 4),
#              'pad_inches': 0.02,
#              }
# 
#     return fig_par


# Path: examples/lowRankTensorApproximations/plots.py
import pickle
import matplotlib as mpl
import matplotlib.pyplot as plt
import os
from examples.lowRankTensorApproximations.fig_pars import set_labels, set_pars


                    for sol_rank in range(0, len(
                            sol_rank_range)):
                        plt.semilogy(list(range(len(res_Ga_Spar[sol_rank]))), res_Ga_Spar[sol_rank],
                                     lines['Ga'][sol_rank],
                                     label='{} {}'.format(labels['Garank'], sol_rank_range[sol_rank]),
                                     markevery=2)

                    ax = plt.gca()
                    plt.xticks(iter_rank_range_set)
                    plt.xlabel(xlabel)
                    ax.set_xlim(xlimit)

                    plt.ylabel(ylabel)
                    ax.set_ylim(ylimit)

                    plt.legend(loc='best')
                    fname = src + 'Residuum_dim{}_mat{}_kind_{}_Ga_{}_N{}{}'.format(dim, material, kind_list[kind],
                                                                                    solver, N, '.pdf')
                    print(('create figure: {}'.format(fname)))
                    plt.savefig(fname, dpi=parf['dpi'], pad_inches=parf['pad_inches'],
                                bbox_inches='tight')
            print('END Ga 3D residuum N={} mat {}'.format(N, material))
            ##### END: figure 5.1 Residuum for Ga solution ###########

            ##### BEGIN: figure 5.2 Residuum for GaNi solution ###########
            for material in material_list:
                for kind in kinds['{}'.format(dim)]:

                    parf = set_pars(mpl)

                    lines, labels = set_labels()