Ejemplo n.º 1
0
def write_imagespec(spec: ImageSpec, hfile: tables.File) -> None:
    hfile.root._v_attrs.crs = spec.crs
    hfile.create_array(hfile.root,
                       name="x_coordinates",
                       obj=spec.x_coordinates)
    hfile.create_array(hfile.root,
                       name="y_coordinates",
                       obj=spec.y_coordinates)
Ejemplo n.º 2
0
def _write_categorical_target_metadata(meta: CategoricalTarget,
                                       hfile: tables.File) -> None:
    hfile.root.categorical_data.attrs.D = meta.D
    hfile.root.categorical_data.attrs.N = meta.N
    _make_str_vlarray(hfile, "categorical_labels", meta.labels)
    _make_int_vlarray(hfile, "categorical_counts", meta.counts)
    _make_int_vlarray(hfile, "categorical_mappings", meta.mappings)
    hfile.create_array(hfile.root,
                       name="categorical_nvalues",
                       obj=meta.nvalues)
Ejemplo n.º 3
0
def _write_continuous_metadata(meta: ContinuousFeatureSet,
                               hfile: tables.File) -> None:
    hfile.root.continuous_data.attrs.missing = meta.missing_value
    hfile.root.continuous_data.attrs.normalised = meta.normalised
    labels = [k for k in meta.columns.keys()]
    D = np.array([v.D for v in meta.columns.values()], dtype=int)
    means = [v.mean for v in meta.columns.values()]
    sds = [v.sd for v in meta.columns.values()]
    _make_str_vlarray(hfile, "continuous_labels", labels)
    hfile.create_array(hfile.root, name="continuous_D", obj=D)
    if meta.normalised:
        _make_float_vlarray(hfile, "continuous_means", means)
        _make_float_vlarray(hfile, "continuous_sds", sds)
Ejemplo n.º 4
0
def _write_categorical_metadata(meta: CategoricalFeatureSet,
                                hfile: tables.File) -> None:
    hfile.root.categorical_data.attrs.missing = meta.missing_value
    labels = [k for k in meta.columns.keys()]
    nvalues = np.array([v.nvalues for v in meta.columns.values()])
    D = np.array([v.D for v in meta.columns.values()])
    mappings = [v.mapping for v in meta.columns.values()]
    counts = [v.counts for v in meta.columns.values()]
    _make_str_vlarray(hfile, "categorical_labels", labels)
    hfile.create_array(hfile.root, name="categorical_D", obj=D)
    _make_int_vlarray(hfile, "categorical_counts", counts)
    _make_int_vlarray(hfile, "categorical_mappings", mappings)
    hfile.create_array(hfile.root, name="categorical_nvalues", obj=nvalues)
Ejemplo n.º 5
0
def _save_array_to_group(hdf_file: tables.File, group: tables.Group, name: str,
                         title: str, data: Any):
    data = utils.convert_to_array_compatible(data)
    hdf_file.create_array(group, name, data, title)
    utils.assert_equal(group[name].read(), data)