Example #1
0
def run(args):
    path_context = data.PathContext.relative()
    plot_location = data.DataLocation(path_context, args.location, args.plot,
                                      "json")

    PlotType = {
        "canvas1d": cplot.Canvas1d,
        "canvas2d": cplot.Canvas2d,
        "plot1d": cplot.Plot1d,
        "plot2d": cplot.Plot2d
    }
    PlotType = PlotType[getattr(args, "type")]

    print(" loading {}...".format(plot_location.computed_path))
    plot = data.load(PlotType, plot_location)

    figsize = [6.4, 4.8] if args.figsize is None else args.figsize
    assert len(figsize) == 2

    fig = plots.figure(figsize=figsize)
    dest = args.dest

    show = (dest is None) if args.show is None else bool(int(args.show))
    fig, ax = plot.plot(fig, show=show, save=False)

    if dest is not None:
        dest_location = data.DataLocation(path_context, args.location, dest,
                                          args.extension)
        print(" saving {}...".format(dest_location.computed_path))
        fig.savefig(dest_location.computed_path)
Example #2
0
def run(args):
    sweeps = json_args(args.sweep)
    assert len(sweeps) > 0 or len(args.sweep_config)

    path_context = data.PathContext.relative()
    testbench_location = data.DataLocation(path_context, args.location, args.source, "json")

    print(" loading {}...".format(testbench_location.computed_path))
    testbench = data.load(sims.StageTestbench, testbench_location)

    sweep_config = []
    for conf_source in args.sweep_config:
        conf_loc = data.DataLocation(path_context, args.location, conf_source, "json")
        print(" loading {}...".format(conf_loc.computed_path))
        sweep_config.append(data.load(gen.ConfigurationSequence, conf_loc))

    if len(sweep_config) > 0:
        print("Sweeping configurations...")
        testbench = sims.StageTestbench(testbench.stages, testbench.ins, sweep_config)

    if len(sweeps) > 0:
        print("Sweeping parameters ...")
        testbench = testbench.sweep_parameters(sweeps)

    testbench_location = data.DataLocation(path_context, args.location, args.dest, "json")
    print(" saving {}...".format(testbench_location.computed_path))
    data.save(testbench, testbench_location)

    save_stages(testbench, path_context, args.location, args.dest)
Example #3
0
def run(args):
    path_context = data.PathContext.relative()
    adcs_location = data.DataLocation(path_context, args.location,
                                      args.adc_source, "json")
    config_location = data.DataLocation(path_context, args.location,
                                        args.config_source, "json")

    array = bool(args.array)
    AdcsType = gen.PipeParameters
    AdcsType = data.list_of(AdcsType) if array else AdcsType

    print(" loading {}...".format(adcs_location.computed_path))
    adcs = data.load(AdcsType, adcs_location)
    print(" loading {}...".format(config_location.computed_path))
    config = data.load(gen.ConfigurationSequence, config_location)

    if not array:
        adcs = [adcs]

    adcs_stages = [adc.as_delta_sigma() for adc in adcs]
    stages = [stages[args.stage_idx] for stages in adcs_stages]
    shape = (len(stages), ) if array else tuple()

    testbench = sims.StageTestbench(stages, args.tests, config, shape=shape)
    testbench_location = data.DataLocation(path_context, args.location,
                                           args.dest, "json")
    print(" saving {}...".format(testbench_location.computed_path))
    data.save(testbench, testbench_location)

    save_stages(testbench, path_context, args.location, args.dest)
Example #4
0
    def test_stage_save_load(self):
        name = "stage.{}"
        name_h = "stage.{}h"

        for n_bits in range(1, 4):
            data_location = data.DataLocation(self.path_context,
                                              self.directory,
                                              name.format(n_bits), "json")
            data_location_h = data.DataLocation(self.path_context,
                                                self.directory,
                                                name_h.format(n_bits), "json")

            meta = gen.StageMeta(n_bits, n_refs=2)
            meta_h = gen.StageMeta(n_bits, n_refs=3, half_bit=True)

            stage = meta.generate_ideal()
            stage_h = meta_h.generate_ideal()

            data.save(stage, data_location)
            data.save(stage_h, data_location_h)

            stage_l = data.load(gen.StageParameters, data_location)
            stage_lh = data.load(gen.StageParameters, data_location_h)

            self.assertEqual(stage, stage_l)
            self.assertEqual(stage_h, stage_lh)
Example #5
0
def prepickle_data(dat, path_context, directory, name):
    real, calibrated, per_snr, cal_snr, nav_snr = dat

    real_str = np.empty_like(real)
    calibrated_str = np.empty_like(calibrated)

    for idx in cartesian(*tuple(range(s) for s in np.shape(real))):
        lname = "{}[{}]".format(name, ','.join(str(ii) for ii in idx))

        real_location = data.DataLocation(path_context, directory, lname + ".real", ".json")
        real_str[idx] = data.save(real[idx], real_location)

        calibrated_location = data.DataLocation(path_context, directory, lname + ".calibrated", ".json")
        calibrated_str[idx] = data.save(calibrated[idx], calibrated_location)

    return real_str, calibrated_str, per_snr, cal_snr, nav_snr
Example #6
0
def run(args):
    path_context = data.PathContext.relative()

    memo = {}
    stages = []

    for stage_name in args.stages:
        location = data.DataLocation(path_context, args.location, stage_name, "json")
        print(" loading {}...".format(location.computed_path))
        stages.append(data.load(gen.StageParameters, location, memo))

    stage_list = data.list_of(gen.StageParameters)(stages * args.repeat)

    list_location = data.DataLocation(path_context, args.location, args.dest, "json")
    print(" saving {}...".format(list_location.computed_path))
    data.save(stage_list, list_location)
Example #7
0
def run(args):
    path_context = data.PathContext.relative()
    stages_location = [
        data.DataLocation(path_context, args.location, source, "json")
        for source in getattr(args, "stages-sources")
    ]

    NestedStages = data.nested_lists_of(gen.StageParameters)

    all_stages = []
    for stage_loc in stages_location:
        print(" loading {}...".format(stage_loc.computed_path))
        stage = data.load(NestedStages, stage_loc)
        all_stages.append(stage)

    assert len(all_stages) > 0
    shape = np.shape(all_stages[0].data)
    assert all(shape == np.shape(stages.data) for stages in all_stages[1:])

    adcs = np.full(shape, None)
    for idx in all_stages[0].iter_idx():
        stages = tuple(stages[idx] for stages in all_stages)
        thresholds = [stage.thres for stage in stages]
        meta0 = stages[0].meta
        thresholds = [
            gen.compute_thres(
                meta0.n_bits, *meta0.fsr, half_bit=meta0.half_bit)
        ] + thresholds
        thresholds, tail = thresholds[:-1], thresholds[-1]

        assert all(stage.meta.n_codes == np.size(thres) + 1
                   for stage, thres in zip(stages, thresholds))
        stages = [
            gen.StageParameters(s.meta, s.eff, s.caps, s.refs, thres,
                                s.common_mode)
            for s, thres in zip(stages, thresholds)
        ]

        adcs[idx] = gen.PipeParameters(stages, tail)

    adcs = data.nested_lists_of(gen.PipeParameters)(adcs.tolist(),
                                                    len(np.shape(adcs)))

    adcs_location = data.DataLocation(path_context, args.location, args.dest,
                                      "json")
    print(" saving {}...".format(adcs_location.computed_path))
    data.save(adcs, adcs_location)
Example #8
0
def run(args):
    path_context = data.PathContext.relative()

    configurations = []
    for conf in args.configurations:
        conf_location = data.DataLocation(path_context, args.location, conf,
                                          "json")
        print(" saving {}...".format(conf_location.computed_path))
        configurations.append(
            data.load(gen.ConfigurationSequence, conf_location))

    stacked = gen.ConfigurationSequence.Stack(*configurations)

    stacked_location = data.DataLocation(path_context, args.location,
                                         args.dest, "json")
    print(" saving {}...".format(stacked_location.computed_path))
    data.save(stacked, stacked_location)
Example #9
0
    def test_meta_save_load(self):
        name = "meta.{}"
        name_h = "meta.{}h"
        dot = data.PathContext.relative()

        for n_bits in range(1, 4):
            data_location = data.DataLocation(dot, self.directory,
                                              name.format(n_bits), "json")
            data_location_h = data.DataLocation(dot, self.directory,
                                                name_h.format(n_bits), "json")

            meta = gen.StageMeta(n_bits, n_refs=2)
            meta_h = gen.StageMeta(n_bits, n_refs=3, half_bit=True)

            data.save(meta, data_location)
            data.save(meta_h, data_location_h)

            meta_l = data.load(gen.StageMeta, data_location)
            meta_lh = data.load(gen.StageMeta, data_location_h)

            self.assertEqual(meta, meta_l)
            self.assertEqual(meta_h, meta_lh)
Example #10
0
def run(args):
    modify = json_args(args.modify)
    path_context = data.PathContext.relative()

    memo = {}
    metas = []

    for meta in args.meta:
        meta_location = data.DataLocation(path_context, args.location, meta,
                                          "json")
        print(" loading {}...".format(meta_location.computed_path))
        meta = data.load(gen.StageMeta, meta_location, memo)
        metas.append(meta)

    assert args.n >= 0

    if args.seed is not None:
        np.random.seed(int(args.seed))

    if args.n == 0:
        adcs = create_single(args, metas, modify)
        ideals = adcs.as_ideal()

    else:
        adcs = [create_single(args, metas, modify) for _ in range(args.n)]
        adcs = data.list_of(gen.PipeParameters)(adcs)
        ideals = [adc.as_ideal() for adc in adcs]
        ideals = data.list_of(gen.PipeParameters)(ideals)

    adc_location = data.DataLocation(path_context, args.location, args.dest,
                                     "json")
    print(" saving {}...".format(adc_location.computed_path))
    data.save(adcs, adc_location)

    ideal_location = data.DataLocation(path_context, args.location,
                                       args.dest + ".ideal", "json")
    print(" saving {}...".format(ideal_location.computed_path))
    data.save(ideals, ideal_location)
Example #11
0
    def plot(self, figure_or_axes=None, show=None, save=None, **plot_kwargs):
        if figure_or_axes is None:
            figure_or_axes = plots.figure()

        if show is None:
            show = save is not True

        if save is None:
            save = not show

        args = (tuple() if self.x is None else (self.x, )) + (self.data, )
        kwargs = dict(self.plot_kwargs)
        kwargs.update(plot_kwargs)

        if not isinstance(figure_or_axes, plots.Figure):
            ax = figure_or_axes
        else:
            ax = figure_or_axes.add_subplot(*self.subplot)

        if self.style == "plot":
            ax.plot(*args, **kwargs)
        elif self.style == "hist":
            ax.hist(*args, **kwargs)
        elif self.style == "scatter":
            ax.scatter(*args, **kwargs)

        figure = ax.get_figure()

        if self.axes_labels is not None:
            try:
                ax.set_xlabel(self.axes_labels[0])
                ax.set_ylabel(self.axes_labels[1])
            except IndexError:
                pass

        if self.title is not None:
            ax.set_title(self.title)

        if save:
            dl = self.data_location
            assert dl is not None
            name = data.DataLocation(dl.path_context, dl.directory, dl.name,
                                     "png")
            name = name.computed_path
            figure.savefig(name)

        if show:
            figure.show()

        return figure, ax
Example #12
0
def save_stages(tb, path_context, location, dest):
    shape = tb.conf_shape + tb.shape
    array = len(shape) > 0

    stages = np.full(shape, None)
    stages_ideal = np.full(shape, None)

    for idx in tb.iter_idx():
        conf_idx, stage_idx = idx
        idx = conf_idx + stage_idx

        real = tb.stages[stage_idx]
        stages[idx] = real

        ideal = real.meta.generate_ideal()
        tail_bits, tail_half = gen.infer_thres_bits(real.thres)
        thres_ideal = gen.compute_thres(tail_bits,
                                        *real.meta.fsr,
                                        half_bit=tail_half)
        ideal._thres = thres_ideal
        stages_ideal[idx] = ideal

    NestedStages = data.nested_lists_of(gen.StageParameters)
    dims = len(shape)
    stages = NestedStages(stages.tolist() if array else stages[tuple()], dims)
    stages_ideal = NestedStages(
        stages_ideal.tolist() if array else stages_ideal[tuple()], dims)

    stages_location = data.DataLocation(path_context, location,
                                        dest + ".stages", "json")
    print(" saving {}...".format(stages_location.computed_path))
    data.save(stages if array else stages[tuple()], stages_location)

    ideal_location = data.DataLocation(path_context, location,
                                       dest + ".stages.ideal", "json")
    print(" saving {}...".format(ideal_location.computed_path))
    data.save(stages_ideal if array else stages_ideal[tuple()], ideal_location)
Example #13
0
def run(args):
    args.full = bool(args.full)

    path_context = data.PathContext.relative()
    meta_location = data.DataLocation(path_context, args.location, args.source,
                                      "json")
    print(" loading {}...".format(meta_location.computed_path))
    meta = data.load(gen.StageMeta, meta_location)

    if args.type == "single":
        c_seq = single(meta, args)
    elif args.type == "standard":
        c_seq = calib(meta, args, False)
    elif args.type == "interlaced":
        c_seq = calib(meta, args, True)
    else:
        raise ValueError("Unexpected type '{}'.".format(args.type))

    print(" Made {} unique configurations.".format(c_seq.n_conf))

    seq_location = data.DataLocation(path_context, args.location, args.dest,
                                     "json")
    print(" saving {}...".format(seq_location.computed_path))
    data.save(c_seq, seq_location)
Example #14
0
def run(args):
    n_bits = args.nbits
    n_refs = default(args.nrefs, 3)

    seed = None if args.seed is None else int(args.seed)

    meta = gen.StageMeta(args.nbits,
                         n_refs,
                         eff=args.eff,
                         cap=args.cap,
                         common_mode=args.common_mode,
                         fsr=(
                             args.min,
                             args.max,
                         ),
                         differential=args.differential,
                         seed=seed)

    data_location = data.DataLocation(data.PathContext.relative(),
                                      args.location, args.dest, "json")
    print(" saving {}...".format(data_location.computed_path))
    data.save(meta, data_location)
Example #15
0
        def plot(self, figure_or_axes=None, show=None, save=None):
            if figure_or_axes is None:
                figure_or_axes = plots.figure()

            if show is None:
                show = save is not True

            if save is None:
                save = not show

            if not isinstance(figure_or_axes, plots.Figure):
                ax = figure_or_axes
            else:
                ax = figure_or_axes.add_subplot(1, 1, 1)

            fig = ax.get_figure()

            for child, label in zip(self._children, self._labels):
                plot_kwargs = {}
                if label is not None:
                    plot_kwargs["label"] = label
                fig, ax = child.plot(ax, show=False, save=False, **plot_kwargs)

            if show:
                plots.legend()
                fig.show()

                plots.show()

            if save:
                dl = self.data_location
                assert dl is not None
                name = data.DataLocation(dl.path_context, dl.directory,
                                         dl.name, "png")
                name = name.computed_path
                fig.savefig(name)

            return fig, ax
Example #16
0
    def plot(self, figure_or_axes=None, show=None, save=None, **plot_kwargs):
        if figure_or_axes is None:
            figure_or_axes = plots.figure()

        if not isinstance(figure_or_axes, plots.Figure):
            ax = figure_or_axes

        else:
            kwargs = {}
            if self.style == "wire":
                kwargs["projection"] = "3d"
            ax = figure_or_axes.add_subplot(*self.subplot, **kwargs)

        figure = ax.get_figure()

        if show is None:
            show = save is not True

        if save is None:
            save = not show

        args = (self.data, )
        kwargs = dict(self.plot_kwargs)
        kwargs.update(plot_kwargs)

        sweeps = self.axes
        if sweeps is None:
            sweeps = tuple(
                list(range(np.size(self.data, ii))) for ii in range(2))

        if self.style == "wire":
            XX, YY = np.meshgrid(sweeps[0], sweeps[1], indexing='ij')
            args = (
                XX,
                YY,
            ) + args
            flip_labels = False

        else:
            kwargs["interpolation"] = kwargs.get("interpolation", 'none')
            extent = [sweeps[0][0], sweeps[0][-1], sweeps[1][0], sweeps[1][-1]]
            kwargs["extent"] = kwargs.get('extent', extent)
            kwargs["origin"] = kwargs.get('origin', 'lower')
            aspect = (extent[1] - extent[0]) / (extent[3] - extent[2])
            kwargs["aspect"] = kwargs.get('aspect', aspect)
            flip_labels = True

        if self.style == "wire":
            sm = ax.plot_wireframe(*args, **kwargs)
        else:
            sm = ax.imshow(*args, **kwargs)

        if self.axes_labels is not None:
            try:
                if flip_labels:
                    ax.set_xlabel(self.axes_labels[1])
                    ax.set_ylabel(self.axes_labels[0])
                else:
                    ax.set_xlabel(self.axes_labels[0])
                    ax.set_ylabel(self.axes_labels[1])

            except IndexError:
                pass

        if self.title is not None:
            ax.set_title(self.title)

        if self.style == "colormap":
            figure.colorbar(sm, ax=ax)

        if save:
            dl = self.data_location
            assert dl is not None
            name = data.DataLocation(dl.path_context, dl.directory, dl.name,
                                     "png")
            name = name.computed_path
            figure.savefig(name)

        if show:
            figure.show()

        return figure, ax
Example #17
0
def run(args):
    path_context = data.PathContext.relative()
    adcs_location = data.DataLocation(path_context, args.location, args.adcs,
                                      "json")
    estimations_location = (adcs_location if args.estimation is None else
                            data.DataLocation(path_context, args.location,
                                              args.estimation, "json"))

    NestedAdcs = data.nested_lists_of(gen.PipeParameters)

    print(" loading {}...".format(adcs_location.computed_path))
    adcs = data.load(NestedAdcs, adcs_location)

    print(" loading {}...".format(estimations_location.computed_path))
    estimations = data.load(NestedAdcs, estimations_location)

    extras = []
    for extra in args.extra:
        extra_location = data.DataLocation(path_context, args.location, extra,
                                           "json")
        print(" loading {}...".format(extra_location.computed_path))
        extras.append(data.load(NestedAdcs, extra_location))

    def snr(real_adc, est_adc):
        magnitude = an.snr(real_adc,
                           est_adc,
                           sampling_factor=args.sampling_factor)
        return an.snr_to_enob(magnitude)

    shape = np.shape(adcs.data)
    assert shape == np.shape(estimations.data)
    for extra in extras:
        assert shape == np.shape(extra.data)

    real_snr = np.empty(shape)
    ideal_snr = np.empty(shape)
    est_snr = np.empty(shape)
    extras_snr = [np.empty(shape) for _ in range(len(extras))]

    iter_idx = (tuple(), ) if len(shape) == 0 else cartesian(*tuple(
        range(ss) for ss in shape))

    for idx in iter_idx:
        real = adcs[idx]
        est = estimations[idx]

        real_snr[idx] = snr(real, real)
        ideal_snr[idx] = snr(real, real.as_ideal())
        est_snr[idx] = snr(real, est)

        for ii, extra in enumerate(extras):
            extras_snr[ii][idx] = snr(real, extra[idx])

    keep_axis = None if args.keep_axis is None else int(args.keep_axis)

    if keep_axis is not None:
        axes = list(range(len(shape)))
        axes.pop(keep_axis)
        axes = tuple(axes)

        def reduce_(arr):
            return (
                np.mean(arr, axis=axes),
                np.std(arr, axis=axes),
            )

    else:

        def reduce_(arr):
            return (
                arr,
                None,
            )

    real_snr = reduce_(real_snr)
    ideal_snr = reduce_(ideal_snr)
    est_snr = reduce_(est_snr)
    extras_snr = [reduce_(e_snr) for e_snr in extras_snr]

    x_param = args.x_param
    if x_param is None:
        canvas = enob_compare(args, real_snr, ideal_snr, est_snr, extras_snr)

    else:
        assert keep_axis is not None
        samples = shape[keep_axis]

        if x_param == 'eff':

            def element(idx):
                return (0, ) * keep_axis + (
                    idx, ) + (0, ) * (len(shape) - 1 - keep_axis)

            samples_idx = tuple(element(ii) for ii in range(samples))

            x_axis = [adcs[idx].stages[0].eff.item() for idx in samples_idx]
            x_label = "Charge transfer efficiency"

        else:
            assert args.testbench is not None, "Testbench required for x-param"

            testbench_loc = data.DataLocation(path_context, args.location,
                                              args.testbench, "json")
            testbench = data.load(sims.StageTestbench, testbench_loc)
            conf_shape = testbench.conf_shape

            def element(idx):
                return (0, ) * keep_axis + (
                    idx, ) + (0, ) * (len(conf_shape) - 1 - keep_axis)

            samples_idx = tuple(element(ii) for ii in range(samples))

            def conf_seq(idx):
                return testbench.configuration_sequence[idx]

            if x_param == 'samples':
                x_axis = [conf_seq(idx).samples for idx in samples_idx]
                x_label = "Samples"

            if x_param == 'switches':
                x_axis = [
                    len(conf_seq(idx).configuration_sets)
                    for idx in samples_idx
                ]
                x_label = "Switching"

        canvas = enob_improvement(args, real_snr, ideal_snr, est_snr,
                                  extras_snr, x_axis, x_label)

    dest_location = data.DataLocation(path_context, args.location, args.dest,
                                      "json")
    print(" saving {}...".format(dest_location.computed_path))
    data.save(canvas, dest_location)
Example #18
0
def run(args):
    seed = None if args.seed is None else int(args.seed)

    path_context = data.PathContext.relative()
    testbench_location = data.DataLocation(path_context, args.location,
                                           args.source, "json")

    cache = bool(args.cache)
    array = bool(args.array)
    serial = bool(args.serial)

    print(" loading {}...".format(testbench_location.computed_path))
    testbench = data.load(sims.StageTestbench, testbench_location)

    simulator = sims.Simulator(seed, args.ref_snr, args.thres_snr,
                               args.test_snr)
    testbenches = testbench.as_scalars() if serial else testbench

    iter_shape = testbench.conf_shape + testbench.shape if serial else tuple()

    codes = np.full(iter_shape, None, dtype=object)
    us = np.full(iter_shape, None, dtype=object)

    iter_idx = tuple(cartesian(*tuple(
        range(ss) for ss in iter_shape))) if serial else (tuple(), )

    for ii, idx in enumerate(iter_idx):
        bench = testbenches[idx] if serial else testbenches
        if cache:
            print(" building cache...")
            for conf_idx in bench.iter_conf_idx():
                bench.configuration_sequence[conf_idx].build_cache()

        print(" simulating...")
        code, u = bench.simulate(simulator,
                                 raise_=bool(getattr(args, "raise")))

        indexes = list(bench.iter_idx())
        fsr = [bench.stages[idx_stage].meta.fsr for _, idx_stage in indexes]
        out_of_range = []
        for ff, fsr_idx in zip(fsr, indexes):
            idx_conf, idx_stage = fsr_idx
            iidx = idx_conf + idx_stage
            outs = np.logical_or(u[iidx + (Ellipsis, )] > ff[1],
                                 u[iidx + (Ellipsis, )] < ff[0])
            if outs.any():
                out_of_range.append((np.sum(outs), np.size(outs), ff))

        for outs in out_of_range:
            sum_, size_, fsr = outs
            warnings.warn(
                "{}/{} samples are out of range (fsr: {}, {})".format(
                    sum_, size_, *fsr))

        codes[idx] = code
        us[idx] = u

    c_name = "{}.c".format(args.dest)
    u_name = "{}.u".format(args.dest)

    if array:
        ext = "json"

        NestedNum = data.nested_lists_of(data.NumpyData)
        data_code = np.full(iter_shape, None)
        data_u = np.full(iter_shape, None)

        for idx in testbench.iter_idx():
            idx = idx[0] + idx[1]
            data_code[idx] = data.at_least_numpydata(codes[idx])
            data_u[idx] = data.at_least_numpydata(us[idx])

        codes = NestedNum(data_code.tolist(), dims=len(np.shape(data_code)))
        us = NestedNum(data_u.tolist(), dims=len(np.shape(data_u)))

        codes.set_children_data_location(
            data.DataLocation(path_context, args.location, c_name, "npy"))
        us.set_children_data_location(
            data.DataLocation(path_context, args.location, u_name, "npy"))

    else:
        codes = np.array(codes.tolist())
        us = np.array(us.tolist())

        samples_index = len(iter_shape)
        if samples_index > 0:
            transpose_indexes = (
                (samples_index, ) + tuple(range(samples_index)) +
                tuple(range(samples_index + 1, len(np.shape(codes)))))

            codes = np.transpose(codes)
            us = np.transpose(us)

        ext = "npy"

    code_location = data.DataLocation(path_context, args.location, c_name, ext)
    u_location = data.DataLocation(path_context, args.location, u_name, ext)

    print(" saving {}...".format(code_location.computed_path))
    data.save(codes, code_location)

    if bool(args.store_u):
        print(" saving {}...".format(u_location.computed_path))
        data.save(us, u_location)