Skip to content

Assignment to data deprecation #8628

Closed
Closed

Description

@mhvk

In 1.12 writing to ndarray.data was deprecated. I'll readily admit that this makes sense, but thought I would point out that it is used "in the wild" to work around windows issues. Specifically, see astropy/astropy#5797, where our tests now fail on a place which has the following interesting note:

            if sys.platform.startswith('win'):
                # On Windows, all the original data mmaps were closed above.
                # However, it's possible that the user still has references to
                # the old data which would no longer work (possibly even cause
                # a segfault if they try to access it).  This replaces the
                # buffers used by the original arrays with the buffers of mmap
                # arrays created from the new file.  This seems to work, but
                # it's a flaming hack and carries no guarantees that it won't
                # lead to odd behavior in practice.  Better to just not keep
                # references to data from files that had to be resized upon
                # flushing (on Windows--again, this is no problem on Linux).
                for idx, mmap, arr in mmaps:
                    if mmap is not None:
>                       arr.data = self[idx].data.data
E                       DeprecationWarning: Assigning the 'data' attribute is an inherently unsafe operation and will be removed in the future.
astropy\io\fits\hdu\hdulist.py:1342: DeprecationWarning

p.s. This code predates most of us currently working on astropy, and we're still trying to figure out what even the problem is and if there are other ways around it (suggestions most welcome).

Activity

  1. mhvk commented on Jan 11, 2024

    @mhvk
    ContributorAuthor

    This issue doesn't really seem actionable, so closing it.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions