question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Empty tables are equal to None but are not None???

See original GitHub issue

Let the code speak for itself:

>>> from astropy.table import Table
>>> Table() is None
False
>>> Table() == None                                                                                                        
True

Why? For me this is unexpected. Is this documented anywhere? Is this a bug?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
mhvkcommented, Apr 29, 2019

Hmm, let me pipe in as table co-maintainer: I consider it a bug that Table() == None evaluates to True.

Looking at the cause, I agree with @mcara that it doesn’t make much sense to return None in as_array for an empty Table - if the user asked for an array, they should get one! So I think returning an empty array is fine, and I like the suggestion to just remove the if clause altogether, as things will work out that way. (Also a nice example of “Special cases aren’t special enough to break the rules”, though we should see whether the next one, “Although practicality beats purity”, holds…)

@mcara - did you already make the change and want to turn it in a PR? If not, @disha012, if you want to try that, that would be great!

Note that it may be that some Table tests will fail - we will then have to look if it is reasonable to change those, or whether that would cause more trouble than it is worth.

0reactions
mhvkcommented, Apr 29, 2019

OK, those tests explicitly were for the code not behaving as documented, so I think it is fine to change them - anyway, just left my very brief review; let’s move further discussion about the changes there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Empty Database value is not None, but an empty string
I have a table defined in the following manner: db.define_table('songinfo', Field('songtitle'), Field('artist')) When I add an empty entry, or upload a CSV ...
Read more >
Joint tables except the empty records (null) - Stack Overflow
I tried but doing so, if the job is null, I cant see any record (no results). Instead I want to see the...
Read more >
How to SELECT Records With No NULL Values in MySQL
Use the MySQL engine to only grab records that you desire while excluding those with pesky NULL columns with the IS NOT NULL...
Read more >
Null Values - Azure Data Explorer | Microsoft Learn
The logical NOT operator not() yields the value bool(null) if the argument is the null value. Null values and the in operator. The...
Read more >
SQL NULL Values - IS NULL and IS NOT NULL - W3Schools
If a field in a table is optional, it is possible to insert a new record or ... A field with a NULL...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found