Skip to content

Fix: Setting mask on non-masked column - #4494

Closed
hvardhanx wants to merge 2 commits into
astropy:masterfrom
hvardhanx:master
Closed

hvardhanx wants to merge 2 commits into
astropy:masterfrom
hvardhanx:master

Conversation

@hvardhanx

Copy link
Copy Markdown

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cheating :)

@hvardhanx

Copy link
Copy Markdown
Author

It wasn't raising an error. 😜

@embray

embray commented Jan 15, 2016

Copy link
Copy Markdown
Member

It looks like there's also already an abandoned PR for this at #3505

@hvardhanx

Copy link
Copy Markdown
Author

Yeah, I saw that :)

@hvardhanx

Copy link
Copy Markdown
Author

Assert statement passes but col just takes up mask and doesn't raise an error.

Comment thread astropy/table/column.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean __setattr__.

That said, I'm not sure overriding __setattr__ is the best approach to this, since it will slow down all attribute access (granted, by a only a small amount).

Instead I think the Column class could get a .mask property defined to raise an exception:

@property
def mask(self):
    raise AttributeError('mask')

Should see what @taldcroft thinks though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand, if a @property is used then it will look on dir() like non-masked columns have a "mask" attribute so that could be confusing after all.

On the third hand, I'm not sure this shouldn't go on BaseColumn since we would want this behavior for any column that doesn't have a mask attribute.

Maybe something like if not hasattr(self, 'mask'): raise AttributeError(...)

@hvardhanx

Copy link
Copy Markdown
Author

Oh, I'll fix that :)

@hvardhanx

Copy link
Copy Markdown
Author

I tried by creating a mask property as suggested by @embray in column class and also tried :

if hasattr(self, 'mask'): raise AttributeError('mask')

Both methods were generating around 700+ errors.

@taldcroft

Copy link
Copy Markdown
Member

Incorrect implementation.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants