Skip to content

Copy constructor returns a view #35

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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