Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Copy constructor returns a view #35

@anuranbaka

Description

@anuranbaka

In Python, calling = causes a reference to be made to the matrix, but in C++ it creates a view. This leads to the following code not being translatable to C++:

import numpy as np
a = np.array([1,2,3,4])
b = a
a.shape = (2,2)
print(b.ndim)

of course in C++ there is no way to set the dims member of an existing matrix anyway, but I worry there may be other ways the abstraction leaks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions