Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASCII fast reader weird behaviour for comments #8360

Open
astronomyk opened this issue Jan 17, 2019 · 3 comments
Open

ASCII fast reader weird behaviour for comments #8360

astronomyk opened this issue Jan 17, 2019 · 3 comments

Comments

@astronomyk
Copy link
Contributor

Hello again!

As always, thanks a ton for all your hard work with astropy! Couldn't live without it =)

Just thought I'd give you another quick heads up to some weird border-case behaviour for the ASCII fast-reader. (Related to issue #8267).

It seems that when I include an additional comment line below my column headers (to keep track of units), this breaks the comment parser of the fast-reader.

This works:

In [159]: ascii.read("""
     ...: # key1 : val 1 
     ...: # key2 : extra long entry
     ...: # key3 : also super long entry
     ...: col1    col2
     ...: 0       1
     ...: """).meta
Out[159]: 
OrderedDict([('comments',
          ['key1 : val 1',
           'key2 : extra long entry',
           'key3 : also super long entry'])])

This doesn't:

In [160]: ascii.read("""
     ...: # key1 : val 1 
     ...: # key2 : extra long entry
     ...: # key3 : also super long entry
     ...: col1    col2
     ...: # unit1 unit2
     ...: 0       1
     ...: """).meta
Out[160]: 
OrderedDict([('comments',
              ['key1 : val 1',
               'key2 : extra long entry',
               'key3 : al',
               '',
               '',
               '',
               '',
               '',
               '',
               '',
               '',
               '',
               '',
               '',
               '',
               '',
               '',
               '',
               '',
               '',
               '',
               '',
               'unit1 unit2'])])

Additionally when I shortened the length of line 2 (--> # key2 : short), the amount of text removed for line 3 (and subsequent lines) changes in proportion to the amount of characters in line 2.

In [164]: ascii.read("""
     ...: # key1 : val 1 
     ...: # key2 : short
     ...: # key3 : also super long entry
     ...: col1    col2
     ...: # unit1 unit2
     ...: 0       1
     ...: """).meta
Out[164]: 
OrderedDict([('comments',
              ['key1 : val 1',
               'key2 : short',
               'key3 : also super lo',
               '',
               '',
               '',
               '',
               '',
               '',
               '',
               '',
               'unit1 unit2'])])

No idea what's going on here though. As stated, my work-around is just to set fast_reader = False, then everything works. Just thought I'd bring it to your attention.

Cheers!

@pllim pllim added the io.ascii label Jan 17, 2019
@pllim
Copy link
Member

pllim commented Jan 17, 2019

Thanks for the report and kind words, @astronomyk ! cc @taldcroft

@pllim pllim added the Bug label Jan 17, 2019
@pllim
Copy link
Member

pllim commented Jan 17, 2019

Also, what Astropy and Python versions are you using?

@astronomyk
Copy link
Contributor Author

I reformatted my operating system on Monday, so everything is brand new from pip

  • Python 3.6.8
  • Astropy 3.1.1

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

No branches or pull requests

2 participants