Skip to content

Improve error message when trying to create an empty table from an empty list #8579

Closed

Description

@samaloney

Trying to create an empty table from an empty list leads to a cryptic error message

from astropy.table import Table
Table([])
. . . 
ValueError: Inconsistent data column lengths: set()

while Table([[]]) works.

The most straightforward solution would probably add a check to the start of the

def _init_from_cols(self, cols):

but looking at the source code it seems that at least one of data, names, dtype or rows must be a non-empty list/dict so it might be more useful to check this at the very start of the __init__?

Activity

  1. samaloney commented on Apr 16, 2019

    @samaloney
    ContributorAuthor

    Slightly related to #4567 and #3811

  2. geekypathak21 commented on May 2, 2019

    @geekypathak21
    Contributor

    To solve this we only need to change the error message or adding a feature so that Table([]) is accepted.

  3. bsipocz commented on May 2, 2019

    @bsipocz
    Member

    #8647 will fix this.

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