Exemple #1
0
def draw_objects(objects,
                 mv_type='interp',
                 color='rgb(0,0,0)',
                 print_scene=True):
    """
    Takes a list of multivectors or a .ga file name and draws the multivectors
    By default attempts to interpret the type of object unless a mv_type is specified
    """
    if isinstance(objects, str):
        data_array, metric, basis_names, support = read_ga_file(objects)
        mv_list = [
            layout.MultiVector(value=data_array[i, :])
            for i in range(data_array.shape[0])
        ]
        sc = GAScene()
        sc.add_object_array(mv_list, mv_type, color=color)
        if print_scene:
            print(sc)
        return sc
    elif isinstance(objects, list) or isinstance(objects, MVArray):
        sc = GAScene()
        sc.add_object_array(objects, mv_type, color=color)
        if print_scene:
            print(sc)
        return sc
    else:
        raise ValueError('The input is not a string or a list of objects')
Exemple #2
0
    def test_write_and_read(self, tmp_path, rng):  # noqa: F811
        file_name = str(tmp_path / "test.ga")

        basis_names = np.array(layout.basis_names, dtype=str)

        mv_array = ConformalMVArray([random_point_pair(rng=rng) for i in range(1000)]).value
        write_ga_file(file_name, mv_array, layout.metric, basis_names, compression=True,
                      transpose=False, sparse=False, support=False)

        data_array, metric_2, basis_names_2, support = read_ga_file(file_name)

        np.testing.assert_equal(data_array, mv_array)
        np.testing.assert_equal(layout.metric, metric_2)
        np.testing.assert_equal(basis_names, basis_names_2)
Exemple #3
0
def draw_objects(objects, mv_type='interp', color='rgb(0,0,0)', print_scene=True):
    """
    Takes a list of multivectors or a .ga file name and draws the multivectors
    By default attempts to interpret the type of object unless a mv_type is specified
    """
    if isinstance(objects, str):
        data_array, metric, basis_names, support = read_ga_file(objects)
        mv_list = [layout.MultiVector(value=data_array[i,:]) for i in range(data_array.shape[0])]
        sc = GAScene()
        sc.add_object_array(mv_list, mv_type, color=color)
        if print_scene:
            print(sc)
        return sc
    elif isinstance(objects, list) or isinstance(objects, MVArray):
        sc = GAScene()
        sc.add_object_array(objects, mv_type, color=color)
        if print_scene:
            print(sc)
        return sc
    else:
        raise ValueError('The input is not a string or a list of objects')