Skip to content

Setting mask on non-masked column should raise error #3505

Closed

Description

@astrofrog

In the following example, the table is not masked, so I feel that for safety we should raise an AttributeError for the last statement:

In [2]: t = Table()

In [3]: t['a'] = [1,2,3]

In [4]: t['a'].mask = [True, False, True]

cc @taldcroft @mhvk

Activity

  1. taldcroft commented on Feb 15, 2015

    @taldcroft
    Member

    Agreed.

  2. taldcroft commented on Feb 15, 2015

    @taldcroft
    Member

    Seems like a __setattr__ on Column should do the trick. It should just look for item == 'mask' and raise an exception, otherwise fall through to the super method. Offhand I don't think there should be any performance implication, but we need to be sure.

  3. taldcroft commented on Feb 15, 2015

    @taldcroft
    Member

    Can leave this open for GSOC PR.

  4. quantshah commented on Feb 15, 2015

    @quantshah

    What message should be issued after AttrributeError is raised ? Will this snippet do the job in astropy/table/column.py ?

    def __setattr__(self,item,value):
            if item == "mask":
                raise AttributeError("Setting mask on non-masked column")
            else:
                return super(Column, self).__setattr__(item, value)

    I got this output with astrofog's test case :

    Traceback (most recent call last):
      File "test.py", line 4, in <module>
        t['a'].mask = [True, False, True]
      File "/home/dev/astropy/astropy/table/column.py", line 780, in __setattr__
        raise AttributeError("Setting mask on non-masked column")
    AttributeError: Setting mask on non-masked column
    
  5. mvnnn commented on Feb 24, 2016

    @mvnnn
    Contributor

    that issue is still open? i want to work on this.

  6. taldcroft commented on Feb 25, 2016

    @taldcroft
    Member

    @mvnnn - Go ahead. You can take over from #3522 and #4494. Both of those were not implemented correctly.

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