Add tests and fix bugs in tabledump and tableload
See original GitHub issueFollow-up to #6937. We should test that these functions work (and that tableload can load files saved with tabledump). Currently the cdfile option for tabledump is broken (and this file is needed to use tableload):
In [7]: fits.tabledump('astropy/io/fits/tests/data/tb.fits', 'foo.txt', hfile='hfile.txt', cdfile='cdfile.txt', overwrite=True)
WARNING: Overwriting existing file 'foo.txt'. [astropy.io.fits.hdu.table]
WARNING: Overwriting existing file 'hfile.txt'. [astropy.io.fits.hdu.table]
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-7-0fcce33a4feb> in <module>()
----> 1 fits.tabledump('astropy/io/fits/tests/data/tb.fits', 'foo.txt', hfile='hfile.txt', cdfile='cdfile.txt', overwrite=True)
~/dev/astropy/astropy/utils/decorators.py in wrapper(*args, **kwargs)
485 # one with the name of the new argument to the function
486 kwargs[new_name[i]] = value
--> 487 return function(*args, **kwargs)
488
489 return wrapper
~/dev/astropy/astropy/io/fits/convenience.py in tabledump(filename, datafile, cdfile, hfile, ext, overwrite)
894
895 # Dump the data from the HDU to the files
--> 896 f[ext].dump(datafile, cdfile, hfile, overwrite)
897 finally:
898 if closed:
~/dev/astropy/astropy/utils/decorators.py in wrapper(*args, **kwargs)
485 # one with the name of the new argument to the function
486 kwargs[new_name[i]] = value
--> 487 return function(*args, **kwargs)
488
489 return wrapper
~/dev/astropy/astropy/io/fits/hdu/table.py in dump(self, datafile, cdfile, hfile, overwrite)
1106 # Process the column definitions
1107 if cdfile:
-> 1108 self._dump_coldefs(cdfile)
1109
1110 # Process the header parameters
~/dev/astropy/astropy/io/fits/hdu/table.py in _dump_coldefs(self, fileobj)
1292 attrs = ['disp', 'unit', 'dim', 'null', 'bscale', 'bzero']
1293 line += ['{:16s}'.format(value if value else '""')
-> 1294 for value in (getattr(column, attr) for attr in attrs)]
1295 fileobj.write(' '.join(line))
1296 fileobj.write('\n')
~/dev/astropy/astropy/io/fits/hdu/table.py in <listcomp>(.0)
1292 attrs = ['disp', 'unit', 'dim', 'null', 'bscale', 'bzero']
1293 line += ['{:16s}'.format(value if value else '""')
-> 1294 for value in (getattr(column, attr) for attr in attrs)]
1295 fileobj.write(' '.join(line))
1296 fileobj.write('\n')
ValueError: Unknown format code 's' for object of type 'int'
(this is another side-effect from aaaa6fb56f - #5432, %s was converting to a string if needed, but {:s} does not do that, cc @bsipocz 😉 )
Issue Analytics
- State:
- Created 6 years ago
- Comments:18 (8 by maintainers)
Top Results From Across the Web
Why a bug fix should "always" include new tests - Matt Lacey
By adding or changing code without adding tests, we risk making future changes harder/slower. Going back to the bug you fixed.
Read more >Finding and fixing bugs in your tests with fast-check
A follow-up to our JavaScript guide that solves a testing bug with property-based testing ... So you add another test case to address...
Read more >Bug Fix via TDD - Software & Solution Architecture Consulting
TDD (Test Driven Development) is a next advancement on top of writing unit tests. Firstly, you need unit tests for defects to ensure...
Read more >issue tracking - Add a unit test for each new bug
In my job all developers that resolve a bug have to add a new unit test that warns about this type of bugs...
Read more >Good practices: First write the test then fix the bug - le0nidas
Finish the task at hand and then add a test for each case you want to explore. You might end up solving more...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I really should not touch fits…
@sbrice - still looks unfixed.