Skip to content

Try to get the fast_reader options to give useful errors when they have no effect #5574

Description

@eteq

This came out of discussions in #5552 (#5552 (comment), #5552 (comment), #5552 (comment)).

The crux of the issue is this: the fast_reader options that get passed into ascii.io.read are silently ignored if the reader is not a "fast" reader. And that's confusing because the options actually affect the output. So it would be much clearer to have the reader raise an exception if the user gives fast_reader options but the reader is not a fast reader.

Or is there some specific reason why that doesn't happen?

I took a shot at this in https://github.com/eteq/astropy/tree/fortranexp2-fast-error but that approach doesn't seem to have worked (although maybe @dhomeier tried it and had better results?)

cc @taldcroft

Activity

  1. dhomeier commented on Dec 9, 2016

    @dhomeier
    Contributor

    One reason is that by default fast_reader is set with a value of True. So my take was to only enforce it if explicitly set as a dict, or with 'force'. Initially this caused at least half of the entire test suite to fail. I found one major problem was that even without guess set, ui.read() would always first call get_reader for a non-fast version, apparently just to get an instance of the Reader, or save 1 or 2 lines of code just after the if fast_reader_param and format is not None....
    Changing that, and checking for the fast_reader option in get_reader as well for selecting a default Reader finally even allowed the auto-format detection to work with the fast readers!
    There were a few more quirks with the guessing, since dictionary-type kwargs are apparently generally passed by reference, getting in particular the fast_reader reset to an empty dict after the first call of the reader instance. And I changed the cparser exception type for column no. mismatches, since a test in test_read was expecting InconsistentTableError here (probably meaning that it had never gotten through to the actual fast reader up to now); that in turn required a whole bunch of the C reader tests to be modified which did expect a CParserError in similar cases. Might be simpler to revert that and just have test_wrong_quote checking for two different error types; OTOH I think it's preferable to have the slow and fast readers throw consistent errors where possible...
    Pushed the updates to the old branch for now.

  2. dhomeier commented on Dec 9, 2016

    @dhomeier
    Contributor

    Created a PR #5578 just for testing purposes for now.

  3. dhomeier commented on Dec 9, 2016

    @dhomeier
    Contributor

    @eteq - looks like #5578 addresses the issues so far, but it does include some nontrivial changes to the guessing logistics, so @plim probably rightly labelled this as experimental. I also think @taldcroft might have a better insight on that part of the code.

  4. bsipocz commented on May 13, 2018

    @bsipocz
    Member

    This has been addressed by #5578, please do reopen if you find it insufficient.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions