Skip to content

Instantly share code, notes, and snippets.

@taldcroft
Created February 12, 2015 17:57
Show Gist options
  • Save taldcroft/9ce97661329b65cb92c0 to your computer and use it in GitHub Desktop.
Save taldcroft/9ce97661329b65cb92c0 to your computer and use it in GitHub Desktop.
skadev-unagi$ python
iActivePython 2.7.1.4 (ActiveState Software Inc.) based on
Python 2.7.1 (r271:86832, Feb 7 2011, 11:30:54)
[GCC 4.0.2 20051125 (Red Hat 4.0.2-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
po>>> import astropy
astropy.test()
WARNING: ConfigurationChangedWarning: The configuration options in astropy 1.0rc2 may have changed, your configuration file was not updated in order to preserve local changes. A new configuration template has been saved to '/home/aldcroft/.astropy/config/astropy.1.0rc2.cfg'. [astropy.config.configuration]
>>> astropy.test()
========================================================== test session starts ===========================================================
platform linux2 -- Python 2.7.1 -- pytest-2.5.1
Running tests with Astropy version 1.0rc2.
Running tests in /proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy.
Platform: Linux-2.6.18-371.12.1.el5.centos.plus-x86_64-with-redhat-5.11-Final
Executable: /proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/bin/python
Full Python Version:
2.7.1 (r271:86832, Feb 7 2011, 11:30:54)
[GCC 4.0.2 20051125 (Red Hat 4.0.2-8)]
encodings: sys: ascii, locale: UTF-8, filesystem: UTF-8, unicode bits: 15
byteorder: little
float info: dig: 15, mant_dig: 15
Numpy: 1.6.2
Scipy: 0.10.1
Matplotlib: 1.2.1
h5py: not available
collected 8467 items / 7 skipped
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/_erfa/tests/test_erfa.py .....
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/analytic_functions/tests/test_blackbody.py ....
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/config/tests/test_configs.py ...............
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/constants/tests/test_constant.py ..............
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/constants/tests/test_pickle.py xxxxxxxxx
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/convolution/tests/test_convolve.py ...............................................................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/convolution/tests/test_convolve_fft.py ...................................................................................................................................................................................................................................................................................................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/convolution/tests/test_convolve_kernels.py ..............................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/convolution/tests/test_discretize.py ...s...........s...............
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/convolution/tests/test_kernel_class.py ............................................................................................................................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/convolution/tests/test_pickle.py .xx.xx.xx
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/test_angles.py ............................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/test_angular_separation.py ....
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/test_api_ape5.py ....s
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/test_arrays.py ..........................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/test_distance.py .........
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/test_earth.py ........................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/test_formatting.py ....................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/test_frames.py .......................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/test_funcs.py ..
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/test_iau_fullstack.py ....................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/test_matching.py ....ss
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/test_name_resolve.py ssssss
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/test_pickle.py ....xx.x...xx.x...xx.x.
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/test_representation.py .............................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/test_sky_coord.py .......................................................................................................................................................................................................................................................................................................................................................................................x.......s......
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/test_transformations.py ......................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/accuracy/test_altaz_icrs.py ...x
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/accuracy/test_fk4_no_e_fk4.py .
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/accuracy/test_fk4_no_e_fk5.py .
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/accuracy/test_galactic_fk4.py .
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/coordinates/tests/accuracy/test_icrs_fk5.py .
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/cosmology/tests/test_cosmology.py ...................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/cosmology/tests/test_pickle.py ...
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/ascii/tests/test_c_reader.py ...........................x................x.......x.x...............
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/ascii/tests/test_cds_header_from_readme.py ...
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/ascii/tests/test_compressed.py .....
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/ascii/tests/test_connect.py ........................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/ascii/tests/test_ecsv.py .......
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/ascii/tests/test_fixedwidth.py ............................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/ascii/tests/test_html.py ........s.......
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/ascii/tests/test_ipac_definitions.py ........................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/ascii/tests/test_read.py ..................................................................................................................................................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/ascii/tests/test_types.py ......
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/ascii/tests/test_write.py ..........................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_checksum.py ....................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_connect.py .........................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_core.py .............................................F....F.....
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_diff.py ..................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_division.py .....
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_groups.py .......
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_hdulist.py .......................F.................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_header.py ..............................................................................................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_image.py ....................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_nonstandard.py F.F
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_structured.py .
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_table.py ................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_uint.py ........
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_util.py .
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/misc/tests/test_hdf5.py sssssssssssssssssssssssssssssssssssssss
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/misc/tests/test_pickle_helpers.py ....
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/tests/test_registry.py ............................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/votable/tests/converter_test.py ............................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/votable/tests/exception_test.py ..
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/votable/tests/table_test.py ..............
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/votable/tests/tree_test.py ...
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/votable/tests/ucd_test.py ..........
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/votable/tests/util_test.py ......................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/votable/tests/vo_test.py ................................................................................................................................................................................................................................................................................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/modeling/tests/test_compound.py ..........................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/modeling/tests/test_constraints.py .....................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/modeling/tests/test_core.py ........
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/modeling/tests/test_fitters.py ...................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/modeling/tests/test_functional_models.py .........
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/modeling/tests/test_input.py ......................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/modeling/tests/test_mappings.py ......
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/modeling/tests/test_models.py .........................................................s.s.s.....................................ss.ssssss...
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/modeling/tests/test_parameters.py .....................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/modeling/tests/test_polynomial.py .................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/modeling/tests/test_projections.py ...................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/modeling/tests/test_rotations.py .....
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/modeling/tests/test_utils.py ..
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/nddata/tests/test_decorators.py ..........
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/nddata/tests/test_flag_collection.py ....................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/nddata/tests/test_nddata.py ....................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/nddata/tests/test_nddata_base.py .
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/nddata/tests/test_utils.py .........
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/stats/tests/test_funcs.py .............
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/stats/tests/test_sigma_clipping.py ...
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/table/tests/test_column.py ....................................................................................................................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/table/tests/test_groups.py ........................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/table/tests/test_init_table.py ......................................................................................................................................................................................................................................................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/table/tests/test_item_access.py ............................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/table/tests/test_jsviewer.py .
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/table/tests/test_masked.py ..................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/table/tests/test_mixin.py ................................................x.
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/table/tests/test_np_utils.py .
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/table/tests/test_operations.py ..........................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/table/tests/test_pickle.py ............
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/table/tests/test_pprint.py ........................................................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/table/tests/test_row.py ....................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/table/tests/test_subclass.py ....
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/table/tests/test_table.py ..........................................................................................................................................................................................................................................................................................x..................................................................................................................................................................................................................................................................................................................x........................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/tests/test_logger.py ............................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/tests/tests/test_imports.py ..
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/tests/tests/test_open_file_detection.py .
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/tests/tests/test_quantity_helpers.py .
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/tests/tests/test_run_tests.py ........
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/tests/tests/test_skip_remote_data.py s
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/tests/tests/test_socketblocker.py ...
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/time/tests/test_basic.py ..............................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/time/tests/test_comparisons.py ...
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/time/tests/test_delta.py ................................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/time/tests/test_guess.py ....
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/time/tests/test_pickle.py .
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/time/tests/test_precision.py .......x..
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/time/tests/test_quantity_interaction.py ............
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/time/tests/test_sidereal.py ...................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/time/tests/test_ut1.py ...s
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/units/tests/test_equivalencies.py ..................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/units/tests/test_format.py ....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/units/tests/test_physical.py ......................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/units/tests/test_quantity.py ....................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/units/tests/test_quantity_array_methods.py ..............x.x............x.......x....x.x.............
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/units/tests/test_quantity_decorator.py sssssssssssss...............
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/units/tests/test_quantity_non_ufuncs.py xx
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/units/tests/test_quantity_ufuncs.py ........................................ss.................................................................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/units/tests/test_units.py ..............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/utils/compat/numpy/tests/test_broadcast_arrays.py ...
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/utils/iers/tests/test_iers.py .s
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/utils/tests/test_codegen.py .
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/utils/tests/test_collections.py .....
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/utils/tests/test_compat.py .
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/utils/tests/test_console.py ..................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/utils/tests/test_data.py .sssss.........s..s..sssss.........s..s.
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/utils/tests/test_decorators.py .......
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/utils/tests/test_gzip.py ss
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/utils/tests/test_introspection.py ....
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/utils/tests/test_metadata.py ...............
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/utils/tests/test_misc.py .s...
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/utils/tests/test_odict.py sssssssssssssssssssssssssssssssssssssssssss
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/utils/tests/test_state.py ..
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/utils/tests/test_timer.py .
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/utils/tests/test_xml.py ........
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/visualization/scripts/tests/test_fits2bitmap.py ..
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/visualization/tests/test_interval.py .................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/visualization/tests/test_norm.py s.....
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/visualization/tests/test_stretch.py ...................................................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/visualization/tests/test_ui.py ......
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/vo/client/tests/test_conesearch.py ssssssssssssss...x.
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/vo/client/tests/test_vos_catalog.py ..............s
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/vo/samp/tests/test_client.py ....
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/vo/samp/tests/test_errors.py ...
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/vo/samp/tests/test_hub.py ..
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/vo/samp/tests/test_hub_proxy.py .....
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/vo/samp/tests/test_hub_script.py .
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/vo/samp/tests/test_standard_profile.py .xx
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/vo/samp/tests/test_web_profile.py X.
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/vo/validator/tests/test_inpect.py ....
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/vo/validator/tests/test_validate.py sss
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/wcs/tests/test_pickle.py .F....
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/wcs/tests/test_profiling.py ..................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/wcs/tests/test_utils.py .........................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/wcs/tests/test_wcs.py ......................................................................................................................................
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/wcs/tests/test_wcsprm.py ...........................................................................................x.....XX
../../proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/wcs/tests/extension/test_extension.py .
================================================================ FAILURES ================================================================
__________________________________________________ TestFileFunctions.test_write_bytesio __________________________________________________
self = <astropy.io.fits.tests.test_core.TestFileFunctions object at 0xe112790>
def test_write_bytesio(self):
"""
Regression test for https://github.com/astropy/astropy/issues/2463
Test againt `io.BytesIO`. `io.StringIO` is not supported.
"""
> self._test_write_string_bytes_io(io.BytesIO())
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_core.py:948:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.tests.test_core.TestFileFunctions object at 0xe112790>, fileobj = <_io.BytesIO object at 0xe01a3b0>
def _test_write_string_bytes_io(self, fileobj):
"""
Implemented for both test_write_stringio and test_write_bytesio.
"""
with fits.open(self.data('test0.fits')) as hdul:
> hdul.writeto(fileobj)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_core.py:973:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0xe0fa190>, <astropy.io.fits....object at 0xe114090>, <astropy.io.fits.hdu.image.ImageHDU object at 0xe10ab10>]
fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0xe01a3b0>>, output_verify = 'exception', clobber = False, checksum = False
def writeto(self, fileobj, output_verify='exception', clobber=False,
checksum=False):
"""
Write the `HDUList` to a new file.
Parameters
----------
fileobj : file path, file object or file-like object
File to write to. If a file object, must be opened in a
writeable mode.
output_verify : str
Output verification option. Must be one of ``"fix"``,
``"silentfix"``, ``"ignore"``, ``"warn"``, or
``"exception"``. May also be any combination of ``"fix"`` or
``"silentfix"`` with ``"+ignore"``, ``+warn``, or ``+exception"
(e.g. ``"fix+warn"``). See :ref:`verify` for more info.
clobber : bool
When `True`, overwrite the output file if exists.
checksum : bool
When `True` adds both ``DATASUM`` and ``CHECKSUM`` cards
to the headers of all HDU's written to the file.
"""
if (len(self) == 0):
warnings.warn("There is nothing to write.", AstropyUserWarning)
return
self.verify(option=output_verify)
# make sure the EXTEND keyword is there if there is extension
self.update_extend()
# make note of whether the input file object is already open, in which
# case we should not close it after writing (that should be the job
# of the caller)
closed = isinstance(fileobj, string_types) or fileobj_closed(fileobj)
# writeto is only for writing a new file from scratch, so the most
# sensible mode to require is 'ostream'. This can accept an open
# file object that's open to write only, or in append/update modes
# but only if the file doesn't exist.
fileobj = _File(fileobj, mode='ostream', clobber=clobber)
hdulist = self.fromfile(fileobj)
for hdu in self:
hdu._prewriteto(checksum=checksum)
try:
> hdu._writeto(hdulist.__file)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/hdulist.py:682:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.hdu.image.ImageHDU object at 0xe121b10>, fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0xe01a3b0>>
inplace = False, copy = False
def _writeto(self, fileobj, inplace=False, copy=False):
# For now fileobj is assumed to be a _File object
if not inplace or self._new:
header_offset, _ = self._writeheader(fileobj)
> data_offset, data_size = self._writedata(fileobj)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/base.py:698:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.hdu.image.ImageHDU object at 0xe121b10>, fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0xe01a3b0>>
def _writedata(self, fileobj):
# TODO: A lot of the simulateonly stuff should be moved back into the
# _File class--basically it should turn write and flush into a noop
offset = 0
size = 0
if not fileobj.simulateonly:
fileobj.flush()
try:
offset = fileobj.tell()
except IOError:
offset = 0
if self._data_loaded or self._data_needs_rescale:
if self.data is not None:
size += self._writedata_internal(fileobj)
# pad the FITS data block
if size > 0:
padding = _pad_length(size) * self._padding_byte
# TODO: Not that this is ever likely, but if for some odd
# reason _padding_byte is > 0x80 this will fail; but really if
# somebody's custom fits format is doing that, they're doing it
# wrong and should be reprimanded harshly.
fileobj.write(padding.encode('ascii'))
size += len(padding)
else:
# The data has not been modified or does not need need to be
# rescaled, so it can be copied, unmodified, directly from an
# existing file or buffer
> size += self._writedata_direct_copy(fileobj)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/base.py:649:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.hdu.image.ImageHDU object at 0xe121b10>, fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0xe01a3b0>>
def _writedata_direct_copy(self, fileobj):
"""Copies the data directly from one file/buffer to the new file.
For now this is handled by loading the raw data from the existing data
(including any padding) via a memory map or from an already in-memory
buffer and using Numpy's existing file-writing facilities to write to
the new file.
If this proves too slow a more direct approach may be used.
"""
raw = self._get_raw_data(self._data_size, 'ubyte', self._data_offset)
if raw is not None:
> _array_to_file(raw, fileobj)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/base.py:685:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
arr = array([ 1, 57, 1, ..., 0, 0, 0], dtype=uint8), outfile = <astropy.io.fits.file._File <_io.BytesIO object at 0xe01a3b0>>
def _array_to_file(arr, outfile):
"""
Write a numpy array to a file or a file-like object.
Parameters
----------
arr : `~numpy.ndarray`
The Numpy array to write.
outfile : file-like
A file-like object such as a Python file object, an `io.BytesIO`, or
anything else with a ``write`` method. The file object must support
the buffer interface in its ``write``.
If writing directly to an on-disk file this delegates directly to
`ndarray.tofile`. Otherwise a slower Python implementation is used.
"""
if isfile(outfile):
write = lambda a, f: a.tofile(f)
else:
write = _array_to_file_like
# Implements a workaround for a bug deep in OSX's stdlib file writing
# functions; on 64-bit OSX it is not possible to correctly write a number
# of bytes greater than 2 ** 32 and divisible by 4096 (or possibly 8192--
# whatever the default blocksize for the filesystem is).
# This issue should have a workaround in Numpy too, but hasn't been
# implemented there yet: https://github.com/astropy/astropy/issues/839
#
# Apparently Windows has its own fwrite bug:
# https://github.com/numpy/numpy/issues/2256
if (sys.platform == 'darwin' and arr.nbytes >= _OSX_WRITE_LIMIT + 1 and
arr.nbytes % 4096 == 0):
# chunksize is a count of elements in the array, not bytes
chunksize = _OSX_WRITE_LIMIT // arr.itemsize
elif sys.platform.startswith('win'):
chunksize = _WIN_WRITE_LIMIT // arr.itemsize
else:
# Just pass the whole array to the write routine
> return write(arr, outfile)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/util.py:675:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
arr = array([ 1, 57, 1, ..., 0, 0, 0], dtype=uint8), fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0xe01a3b0>>
def _array_to_file_like(arr, fileobj):
"""
Write a `~numpy.ndarray` to a file-like object (which is not supported by
`numpy.ndarray.tofile`).
"""
if arr.flags.contiguous:
# It suffices to just pass the underlying buffer directly to the
# fileobj's write (assuming it supports the buffer interface, which
# unfortunately there's no simple way to check)
> fileobj.write(arr.data)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/util.py:696:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.file._File <_io.BytesIO object at 0xe01a3b0>>
string = <read-write buffer for 0xe649d80, size 5760, offset 0 at 0xe10abf0>
def write(self, string):
if hasattr(self.__file, 'write'):
> _write_string(self.__file, string)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/file.py:268:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
f = <_io.BytesIO object at 0xe01a3b0>, s = <read-write buffer for 0xe649d80, size 5760, offset 0 at 0xe10abf0>
def _write_string(f, s):
"""
Write a string to a file, encoding to ASCII if the file is open in binary
mode, or decoding if the file is open in text mode.
"""
# Assume if the file object doesn't have a specific mode, that the mode is
# binary
binmode = fileobj_is_binary(f)
if binmode and isinstance(s, text_type):
s = encode_ascii(s)
elif not binmode and not isinstance(f, text_type):
s = decode_ascii(s)
elif isinstance(f, StringIO) and isinstance(s, np.ndarray):
# Workaround for StringIO/ndarray incompatibility
s = s.data
> f.write(s)
E TypeError: 'buffer' does not have the buffer interface
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/util.py:732: TypeError
_______________________________________ TestStreamingFunctions.test_streaming_hdu_write_file_like ________________________________________
self = <astropy.io.fits.tests.test_core.TestStreamingFunctions object at 0xcd10850>
def test_streaming_hdu_write_file_like(self):
"""Test streaming an HDU to an open file-like object."""
arr = np.zeros((5, 5), dtype=np.int32)
# The file-like object underlying a StreamingHDU must be in binary mode
sf = io.BytesIO()
shdu = self._make_streaming_hdu(sf)
> shdu.write(arr)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_core.py:1033:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.hdu.streaming.StreamingHDU object at 0xe497e90>
data = array([[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]], dtype=int32)
def write(self, data):
"""
Write the given data to the stream.
Parameters
----------
data : ndarray
Data to stream to the file.
Returns
-------
writecomplete : int
Flag that when `True` indicates that all of the required
data has been written to the stream.
Notes
-----
Only the amount of data specified in the header provided to the class
constructor may be written to the stream. If the provided data would
cause the stream to overflow, an `~.exceptions.IOError` exception is
raised and the data is not written. Once sufficient data has been
written to the stream to satisfy the amount specified in the header,
the stream is padded to fill a complete FITS block and no more data
will be accepted. An attempt to write more data after the stream has
been filled will raise an `~.exceptions.IOError` exception. If the
dtype of the input data does not match what is expected by the header,
a `.exceptions.TypeError` exception is raised.
"""
size = self._ffo.tell() - self._data_offset
if self.writecomplete or size + data.nbytes > self._size:
raise IOError('Attempt to write more data to the stream than the '
'header specified.')
if _ImageBaseHDU.NumCode[self._header['BITPIX']] != data.dtype.name:
raise TypeError('Supplied data does not match the type specified '
'in the header.')
if data.dtype.str[0] != '>':
# byteswap little endian arrays before writing
output = data.byteswap()
else:
output = data
> self._ffo.writearray(output)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/streaming.py:184:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.file._File <_io.BytesIO object at 0xe01ead0>>
array = array([[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]], dtype=int32)
def writearray(self, array):
"""
Similar to file.write(), but writes a numpy array instead of a string.
Also like file.write(), a flush() or close() may be needed before
the file on disk reflects the data written.
"""
if hasattr(self.__file, 'write'):
> _array_to_file(array, self.__file)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/file.py:279:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
arr = array([[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]], dtype=int32)
outfile = <_io.BytesIO object at 0xe01ead0>
def _array_to_file(arr, outfile):
"""
Write a numpy array to a file or a file-like object.
Parameters
----------
arr : `~numpy.ndarray`
The Numpy array to write.
outfile : file-like
A file-like object such as a Python file object, an `io.BytesIO`, or
anything else with a ``write`` method. The file object must support
the buffer interface in its ``write``.
If writing directly to an on-disk file this delegates directly to
`ndarray.tofile`. Otherwise a slower Python implementation is used.
"""
if isfile(outfile):
write = lambda a, f: a.tofile(f)
else:
write = _array_to_file_like
# Implements a workaround for a bug deep in OSX's stdlib file writing
# functions; on 64-bit OSX it is not possible to correctly write a number
# of bytes greater than 2 ** 32 and divisible by 4096 (or possibly 8192--
# whatever the default blocksize for the filesystem is).
# This issue should have a workaround in Numpy too, but hasn't been
# implemented there yet: https://github.com/astropy/astropy/issues/839
#
# Apparently Windows has its own fwrite bug:
# https://github.com/numpy/numpy/issues/2256
if (sys.platform == 'darwin' and arr.nbytes >= _OSX_WRITE_LIMIT + 1 and
arr.nbytes % 4096 == 0):
# chunksize is a count of elements in the array, not bytes
chunksize = _OSX_WRITE_LIMIT // arr.itemsize
elif sys.platform.startswith('win'):
chunksize = _WIN_WRITE_LIMIT // arr.itemsize
else:
# Just pass the whole array to the write routine
> return write(arr, outfile)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/util.py:675:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
arr = array([[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]], dtype=int32)
fileobj = <_io.BytesIO object at 0xe01ead0>
def _array_to_file_like(arr, fileobj):
"""
Write a `~numpy.ndarray` to a file-like object (which is not supported by
`numpy.ndarray.tofile`).
"""
if arr.flags.contiguous:
# It suffices to just pass the underlying buffer directly to the
# fileobj's write (assuming it supports the buffer interface, which
# unfortunately there's no simple way to check)
> fileobj.write(arr.data)
E TypeError: 'buffer' does not have the buffer interface
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/util.py:696: TypeError
_______________________________________________ TestHDUListFunctions.test_update_filelike ________________________________________________
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0xe10ad10>
def test_update_filelike(self):
"""Test opening a file-like object in update mode and resizing the
HDU.
"""
sf = io.BytesIO()
arr = np.zeros((100, 100))
hdu = fits.PrimaryHDU(data=arr)
> hdu.writeto(sf)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_hdulist.py:402:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.hdu.image.PrimaryHDU object at 0xe10ad90>, name = <_io.BytesIO object at 0xdab3410>, output_verify = 'exception'
clobber = False, checksum = False
def writeto(self, name, output_verify='exception', clobber=False,
checksum=False):
"""
Write the HDU to a new file. This is a convenience method to
provide a user easier output interface if only one HDU needs
to be written to a file.
Parameters
----------
name : file path, file object or file-like object
Output FITS file. If the file object is already opened, it must
be opened in a writeable mode.
output_verify : str
Output verification option. Must be one of ``"fix"``,
``"silentfix"``, ``"ignore"``, ``"warn"``, or
``"exception"``. May also be any combination of ``"fix"`` or
``"silentfix"`` with ``"+ignore"``, ``+warn``, or ``+exception"
(e.g. ``"fix+warn"``). See :ref:`verify` for more info.
clobber : bool
Overwrite the output file if exists.
checksum : bool
When `True` adds both ``DATASUM`` and ``CHECKSUM`` cards
to the header of the HDU when written to the file.
"""
from .hdulist import HDUList
hdulist = HDUList([self])
hdulist.writeto(name, output_verify, clobber=clobber,
> checksum=checksum)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/base.py:417:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0xe10ad90>]
fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0xdab3410>>, output_verify = 'exception', clobber = False, checksum = False
def writeto(self, fileobj, output_verify='exception', clobber=False,
checksum=False):
"""
Write the `HDUList` to a new file.
Parameters
----------
fileobj : file path, file object or file-like object
File to write to. If a file object, must be opened in a
writeable mode.
output_verify : str
Output verification option. Must be one of ``"fix"``,
``"silentfix"``, ``"ignore"``, ``"warn"``, or
``"exception"``. May also be any combination of ``"fix"`` or
``"silentfix"`` with ``"+ignore"``, ``+warn``, or ``+exception"
(e.g. ``"fix+warn"``). See :ref:`verify` for more info.
clobber : bool
When `True`, overwrite the output file if exists.
checksum : bool
When `True` adds both ``DATASUM`` and ``CHECKSUM`` cards
to the headers of all HDU's written to the file.
"""
if (len(self) == 0):
warnings.warn("There is nothing to write.", AstropyUserWarning)
return
self.verify(option=output_verify)
# make sure the EXTEND keyword is there if there is extension
self.update_extend()
# make note of whether the input file object is already open, in which
# case we should not close it after writing (that should be the job
# of the caller)
closed = isinstance(fileobj, string_types) or fileobj_closed(fileobj)
# writeto is only for writing a new file from scratch, so the most
# sensible mode to require is 'ostream'. This can accept an open
# file object that's open to write only, or in append/update modes
# but only if the file doesn't exist.
fileobj = _File(fileobj, mode='ostream', clobber=clobber)
hdulist = self.fromfile(fileobj)
for hdu in self:
hdu._prewriteto(checksum=checksum)
try:
> hdu._writeto(hdulist.__file)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/hdulist.py:682:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.hdu.image.PrimaryHDU object at 0xe10ad90>
fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0xdab3410>>, inplace = False, copy = False
def _writeto(self, fileobj, inplace=False, copy=False):
# For now fileobj is assumed to be a _File object
if not inplace or self._new:
header_offset, _ = self._writeheader(fileobj)
> data_offset, data_size = self._writedata(fileobj)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/base.py:698:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.hdu.image.PrimaryHDU object at 0xe10ad90>
fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0xdab3410>>
def _writedata(self, fileobj):
# TODO: A lot of the simulateonly stuff should be moved back into the
# _File class--basically it should turn write and flush into a noop
offset = 0
size = 0
if not fileobj.simulateonly:
fileobj.flush()
try:
offset = fileobj.tell()
except IOError:
offset = 0
if self._data_loaded or self._data_needs_rescale:
if self.data is not None:
> size += self._writedata_internal(fileobj)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/base.py:635:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.hdu.image.PrimaryHDU object at 0xe10ad90>
fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0xdab3410>>
def _writedata_internal(self, fileobj):
size = 0
if self.data is not None:
# Based on the system type, determine the byteorders that
# would need to be swapped to get to big-endian output
if sys.byteorder == 'little':
swap_types = ('<', '=')
else:
swap_types = ('<',)
# deal with unsigned integer 16, 32 and 64 data
if _is_pseudo_unsigned(self.data.dtype):
# Convert the unsigned array to signed
output = np.array(
self.data - _unsigned_zero(self.data.dtype),
dtype='>i%d' % self.data.dtype.itemsize)
should_swap = False
else:
output = self.data
byteorder = output.dtype.str[0]
should_swap = (byteorder in swap_types)
if not fileobj.simulateonly:
if should_swap:
output.byteswap(True)
try:
> fileobj.writearray(output)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/image.py:521:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.file._File <_io.BytesIO object at 0xdab3410>>
array = array([[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., ...0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.]])
def writearray(self, array):
"""
Similar to file.write(), but writes a numpy array instead of a string.
Also like file.write(), a flush() or close() may be needed before
the file on disk reflects the data written.
"""
if hasattr(self.__file, 'write'):
> _array_to_file(array, self.__file)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/file.py:279:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
arr = array([[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., ...0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.]])
outfile = <_io.BytesIO object at 0xdab3410>
def _array_to_file(arr, outfile):
"""
Write a numpy array to a file or a file-like object.
Parameters
----------
arr : `~numpy.ndarray`
The Numpy array to write.
outfile : file-like
A file-like object such as a Python file object, an `io.BytesIO`, or
anything else with a ``write`` method. The file object must support
the buffer interface in its ``write``.
If writing directly to an on-disk file this delegates directly to
`ndarray.tofile`. Otherwise a slower Python implementation is used.
"""
if isfile(outfile):
write = lambda a, f: a.tofile(f)
else:
write = _array_to_file_like
# Implements a workaround for a bug deep in OSX's stdlib file writing
# functions; on 64-bit OSX it is not possible to correctly write a number
# of bytes greater than 2 ** 32 and divisible by 4096 (or possibly 8192--
# whatever the default blocksize for the filesystem is).
# This issue should have a workaround in Numpy too, but hasn't been
# implemented there yet: https://github.com/astropy/astropy/issues/839
#
# Apparently Windows has its own fwrite bug:
# https://github.com/numpy/numpy/issues/2256
if (sys.platform == 'darwin' and arr.nbytes >= _OSX_WRITE_LIMIT + 1 and
arr.nbytes % 4096 == 0):
# chunksize is a count of elements in the array, not bytes
chunksize = _OSX_WRITE_LIMIT // arr.itemsize
elif sys.platform.startswith('win'):
chunksize = _WIN_WRITE_LIMIT // arr.itemsize
else:
# Just pass the whole array to the write routine
> return write(arr, outfile)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/util.py:675:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
arr = array([[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., ...0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.]])
fileobj = <_io.BytesIO object at 0xdab3410>
def _array_to_file_like(arr, fileobj):
"""
Write a `~numpy.ndarray` to a file-like object (which is not supported by
`numpy.ndarray.tofile`).
"""
if arr.flags.contiguous:
# It suffices to just pass the underlying buffer directly to the
# fileobj's write (assuming it supports the buffer interface, which
# unfortunately there's no simple way to check)
> fileobj.write(arr.data)
E TypeError: 'buffer' does not have the buffer interface
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/util.py:696: TypeError
________________________________________________ TestNonstandardHdus.test_create_fitshdu _________________________________________________
self = <astropy.io.fits.tests.test_nonstandard.TestNonstandardHdus object at 0xea99f10>
def test_create_fitshdu(self):
"""
A round trip test of creating a FitsHDU, adding a FITS file to it,
writing the FitsHDU out as part of a new FITS file, and then reading
it and recovering the original FITS file.
"""
> self._test_create_fitshdu(compression=False)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_nonstandard.py:17:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.tests.test_nonstandard.TestNonstandardHdus object at 0xea99f10>, compression = False
def _test_create_fitshdu(self, compression=False):
hdul_orig = fits.open(self.data('test0.fits'),
do_not_scale_image_data=True)
> fitshdu = fits.FitsHDU.fromhdulist(hdul_orig, compress=compression)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_nonstandard.py:49:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'astropy.io.fits.hdu.nonstandard.FitsHDU'>
hdulist = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0xea7a8d0>, <astropy.io.fits....object at 0xea708d0>, <astropy.io.fits.hdu.image.ImageHDU object at 0xea66a10>]
compress = False
@classmethod
def fromhdulist(cls, hdulist, compress=False):
"""
Creates a new FitsHDU from a given HDUList object.
Parameters
----------
hdulist : HDUList
A valid Headerlet object.
compress : bool, optional
Gzip compress the FITS file
"""
fileobj = bs = io.BytesIO()
if compress:
if hasattr(hdulist, '_file'):
name = fileobj_name(hdulist._file)
else:
name = None
fileobj = gzip.GzipFile(name, mode='wb', fileobj=bs)
> hdulist.writeto(fileobj)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/nonstandard.py:79:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0xea7a8d0>, <astropy.io.fits....object at 0xea708d0>, <astropy.io.fits.hdu.image.ImageHDU object at 0xea66a10>]
fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0xedbb770>>, output_verify = 'exception', clobber = False, checksum = False
def writeto(self, fileobj, output_verify='exception', clobber=False,
checksum=False):
"""
Write the `HDUList` to a new file.
Parameters
----------
fileobj : file path, file object or file-like object
File to write to. If a file object, must be opened in a
writeable mode.
output_verify : str
Output verification option. Must be one of ``"fix"``,
``"silentfix"``, ``"ignore"``, ``"warn"``, or
``"exception"``. May also be any combination of ``"fix"`` or
``"silentfix"`` with ``"+ignore"``, ``+warn``, or ``+exception"
(e.g. ``"fix+warn"``). See :ref:`verify` for more info.
clobber : bool
When `True`, overwrite the output file if exists.
checksum : bool
When `True` adds both ``DATASUM`` and ``CHECKSUM`` cards
to the headers of all HDU's written to the file.
"""
if (len(self) == 0):
warnings.warn("There is nothing to write.", AstropyUserWarning)
return
self.verify(option=output_verify)
# make sure the EXTEND keyword is there if there is extension
self.update_extend()
# make note of whether the input file object is already open, in which
# case we should not close it after writing (that should be the job
# of the caller)
closed = isinstance(fileobj, string_types) or fileobj_closed(fileobj)
# writeto is only for writing a new file from scratch, so the most
# sensible mode to require is 'ostream'. This can accept an open
# file object that's open to write only, or in append/update modes
# but only if the file doesn't exist.
fileobj = _File(fileobj, mode='ostream', clobber=clobber)
hdulist = self.fromfile(fileobj)
for hdu in self:
hdu._prewriteto(checksum=checksum)
try:
> hdu._writeto(hdulist.__file)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/hdulist.py:682:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.hdu.image.PrimaryHDU object at 0xea7a8d0>
fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0xedbb770>>, inplace = False, copy = False
def _writeto(self, fileobj, inplace=False, copy=False):
# For now fileobj is assumed to be a _File object
if not inplace or self._new:
header_offset, _ = self._writeheader(fileobj)
> data_offset, data_size = self._writedata(fileobj)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/base.py:698:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.hdu.image.PrimaryHDU object at 0xea7a8d0>
fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0xedbb770>>
def _writedata(self, fileobj):
# TODO: A lot of the simulateonly stuff should be moved back into the
# _File class--basically it should turn write and flush into a noop
offset = 0
size = 0
if not fileobj.simulateonly:
fileobj.flush()
try:
offset = fileobj.tell()
except IOError:
offset = 0
if self._data_loaded or self._data_needs_rescale:
if self.data is not None:
size += self._writedata_internal(fileobj)
# pad the FITS data block
if size > 0:
padding = _pad_length(size) * self._padding_byte
# TODO: Not that this is ever likely, but if for some odd
# reason _padding_byte is > 0x80 this will fail; but really if
# somebody's custom fits format is doing that, they're doing it
# wrong and should be reprimanded harshly.
fileobj.write(padding.encode('ascii'))
size += len(padding)
else:
# The data has not been modified or does not need need to be
# rescaled, so it can be copied, unmodified, directly from an
# existing file or buffer
> size += self._writedata_direct_copy(fileobj)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/base.py:649:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.hdu.image.PrimaryHDU object at 0xea7a8d0>
fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0xedbb770>>
def _writedata_direct_copy(self, fileobj):
"""Copies the data directly from one file/buffer to the new file.
For now this is handled by loading the raw data from the existing data
(including any padding) via a memory map or from an already in-memory
buffer and using Numpy's existing file-writing facilities to write to
the new file.
If this proves too slow a more direct approach may be used.
"""
raw = self._get_raw_data(self._data_size, 'ubyte', self._data_offset)
if raw is not None:
> _array_to_file(raw, fileobj)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/base.py:685:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
arr = array([], dtype=uint8), outfile = <astropy.io.fits.file._File <_io.BytesIO object at 0xedbb770>>
def _array_to_file(arr, outfile):
"""
Write a numpy array to a file or a file-like object.
Parameters
----------
arr : `~numpy.ndarray`
The Numpy array to write.
outfile : file-like
A file-like object such as a Python file object, an `io.BytesIO`, or
anything else with a ``write`` method. The file object must support
the buffer interface in its ``write``.
If writing directly to an on-disk file this delegates directly to
`ndarray.tofile`. Otherwise a slower Python implementation is used.
"""
if isfile(outfile):
write = lambda a, f: a.tofile(f)
else:
write = _array_to_file_like
# Implements a workaround for a bug deep in OSX's stdlib file writing
# functions; on 64-bit OSX it is not possible to correctly write a number
# of bytes greater than 2 ** 32 and divisible by 4096 (or possibly 8192--
# whatever the default blocksize for the filesystem is).
# This issue should have a workaround in Numpy too, but hasn't been
# implemented there yet: https://github.com/astropy/astropy/issues/839
#
# Apparently Windows has its own fwrite bug:
# https://github.com/numpy/numpy/issues/2256
if (sys.platform == 'darwin' and arr.nbytes >= _OSX_WRITE_LIMIT + 1 and
arr.nbytes % 4096 == 0):
# chunksize is a count of elements in the array, not bytes
chunksize = _OSX_WRITE_LIMIT // arr.itemsize
elif sys.platform.startswith('win'):
chunksize = _WIN_WRITE_LIMIT // arr.itemsize
else:
# Just pass the whole array to the write routine
> return write(arr, outfile)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/util.py:675:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
arr = array([], dtype=uint8), fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0xedbb770>>
def _array_to_file_like(arr, fileobj):
"""
Write a `~numpy.ndarray` to a file-like object (which is not supported by
`numpy.ndarray.tofile`).
"""
if arr.flags.contiguous:
# It suffices to just pass the underlying buffer directly to the
# fileobj's write (assuming it supports the buffer interface, which
# unfortunately there's no simple way to check)
> fileobj.write(arr.data)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/util.py:696:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.file._File <_io.BytesIO object at 0xedbb770>>
string = <read-write buffer for 0xe8685d0, size 0, offset 0 at 0xea66af0>
def write(self, string):
if hasattr(self.__file, 'write'):
> _write_string(self.__file, string)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/file.py:268:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
f = <_io.BytesIO object at 0xedbb770>, s = <read-write buffer for 0xe8685d0, size 0, offset 0 at 0xea66af0>
def _write_string(f, s):
"""
Write a string to a file, encoding to ASCII if the file is open in binary
mode, or decoding if the file is open in text mode.
"""
# Assume if the file object doesn't have a specific mode, that the mode is
# binary
binmode = fileobj_is_binary(f)
if binmode and isinstance(s, text_type):
s = encode_ascii(s)
elif not binmode and not isinstance(f, text_type):
s = decode_ascii(s)
elif isinstance(f, StringIO) and isinstance(s, np.ndarray):
# Workaround for StringIO/ndarray incompatibility
s = s.data
> f.write(s)
E TypeError: 'buffer' does not have the buffer interface
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/util.py:732: TypeError
_________________________________________ TestNonstandardHdus.test_create_fitshdu_from_filename __________________________________________
self = <astropy.io.fits.tests.test_nonstandard.TestNonstandardHdus object at 0xea92550>
def test_create_fitshdu_from_filename(self):
"""Regression test on `FitsHDU.fromfile`"""
# Build up a simple test FITS file
a = np.arange(100)
phdu = fits.PrimaryHDU(data=a)
phdu.header['TEST1'] = 'A'
phdu.header['TEST2'] = 'B'
imghdu = fits.ImageHDU(data=a + 1)
phdu.header['TEST3'] = 'C'
phdu.header['TEST4'] = 'D'
hdul = fits.HDUList([phdu, imghdu])
hdul.writeto(self.temp('test.fits'))
> fitshdu = fits.FitsHDU.fromfile(self.temp('test.fits'))
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/tests/test_nonstandard.py:39:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'astropy.io.fits.hdu.nonstandard.FitsHDU'>, filename = '/tmp/fits-test-rjfz0V/test.fits', compress = False
@classmethod
def fromfile(cls, filename, compress=False):
"""
Like `FitsHDU.fromhdulist()`, but creates a FitsHDU from a file on
disk.
Parameters
----------
filename : str
The path to the file to read into a FitsHDU
compress : bool, optional
Gzip compress the FITS file
"""
> return cls.fromhdulist(HDUList.fromfile(filename), compress=compress)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/nonstandard.py:56:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'astropy.io.fits.hdu.nonstandard.FitsHDU'>
hdulist = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0xea92f10>, <astropy.io.fits.hdu.image.ImageHDU object at 0xea7fb10>]
compress = False
@classmethod
def fromhdulist(cls, hdulist, compress=False):
"""
Creates a new FitsHDU from a given HDUList object.
Parameters
----------
hdulist : HDUList
A valid Headerlet object.
compress : bool, optional
Gzip compress the FITS file
"""
fileobj = bs = io.BytesIO()
if compress:
if hasattr(hdulist, '_file'):
name = fileobj_name(hdulist._file)
else:
name = None
fileobj = gzip.GzipFile(name, mode='wb', fileobj=bs)
> hdulist.writeto(fileobj)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/nonstandard.py:79:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0xea92f10>, <astropy.io.fits.hdu.image.ImageHDU object at 0xea7fb10>]
fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0xe489710>>, output_verify = 'exception', clobber = False, checksum = False
def writeto(self, fileobj, output_verify='exception', clobber=False,
checksum=False):
"""
Write the `HDUList` to a new file.
Parameters
----------
fileobj : file path, file object or file-like object
File to write to. If a file object, must be opened in a
writeable mode.
output_verify : str
Output verification option. Must be one of ``"fix"``,
``"silentfix"``, ``"ignore"``, ``"warn"``, or
``"exception"``. May also be any combination of ``"fix"`` or
``"silentfix"`` with ``"+ignore"``, ``+warn``, or ``+exception"
(e.g. ``"fix+warn"``). See :ref:`verify` for more info.
clobber : bool
When `True`, overwrite the output file if exists.
checksum : bool
When `True` adds both ``DATASUM`` and ``CHECKSUM`` cards
to the headers of all HDU's written to the file.
"""
if (len(self) == 0):
warnings.warn("There is nothing to write.", AstropyUserWarning)
return
self.verify(option=output_verify)
# make sure the EXTEND keyword is there if there is extension
self.update_extend()
# make note of whether the input file object is already open, in which
# case we should not close it after writing (that should be the job
# of the caller)
closed = isinstance(fileobj, string_types) or fileobj_closed(fileobj)
# writeto is only for writing a new file from scratch, so the most
# sensible mode to require is 'ostream'. This can accept an open
# file object that's open to write only, or in append/update modes
# but only if the file doesn't exist.
fileobj = _File(fileobj, mode='ostream', clobber=clobber)
hdulist = self.fromfile(fileobj)
for hdu in self:
hdu._prewriteto(checksum=checksum)
try:
> hdu._writeto(hdulist.__file)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/hdulist.py:682:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.hdu.image.PrimaryHDU object at 0xea92f10>
fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0xe489710>>, inplace = False, copy = False
def _writeto(self, fileobj, inplace=False, copy=False):
# For now fileobj is assumed to be a _File object
if not inplace or self._new:
header_offset, _ = self._writeheader(fileobj)
> data_offset, data_size = self._writedata(fileobj)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/base.py:698:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.hdu.image.PrimaryHDU object at 0xea92f10>
fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0xe489710>>
def _writedata(self, fileobj):
# TODO: A lot of the simulateonly stuff should be moved back into the
# _File class--basically it should turn write and flush into a noop
offset = 0
size = 0
if not fileobj.simulateonly:
fileobj.flush()
try:
offset = fileobj.tell()
except IOError:
offset = 0
if self._data_loaded or self._data_needs_rescale:
if self.data is not None:
size += self._writedata_internal(fileobj)
# pad the FITS data block
if size > 0:
padding = _pad_length(size) * self._padding_byte
# TODO: Not that this is ever likely, but if for some odd
# reason _padding_byte is > 0x80 this will fail; but really if
# somebody's custom fits format is doing that, they're doing it
# wrong and should be reprimanded harshly.
fileobj.write(padding.encode('ascii'))
size += len(padding)
else:
# The data has not been modified or does not need need to be
# rescaled, so it can be copied, unmodified, directly from an
# existing file or buffer
> size += self._writedata_direct_copy(fileobj)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/base.py:649:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.hdu.image.PrimaryHDU object at 0xea92f10>
fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0xe489710>>
def _writedata_direct_copy(self, fileobj):
"""Copies the data directly from one file/buffer to the new file.
For now this is handled by loading the raw data from the existing data
(including any padding) via a memory map or from an already in-memory
buffer and using Numpy's existing file-writing facilities to write to
the new file.
If this proves too slow a more direct approach may be used.
"""
raw = self._get_raw_data(self._data_size, 'ubyte', self._data_offset)
if raw is not None:
> _array_to_file(raw, fileobj)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/base.py:685:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
arr = array([0, 0, 0, ..., 0, 0, 0], dtype=uint8), outfile = <astropy.io.fits.file._File <_io.BytesIO object at 0xe489710>>
def _array_to_file(arr, outfile):
"""
Write a numpy array to a file or a file-like object.
Parameters
----------
arr : `~numpy.ndarray`
The Numpy array to write.
outfile : file-like
A file-like object such as a Python file object, an `io.BytesIO`, or
anything else with a ``write`` method. The file object must support
the buffer interface in its ``write``.
If writing directly to an on-disk file this delegates directly to
`ndarray.tofile`. Otherwise a slower Python implementation is used.
"""
if isfile(outfile):
write = lambda a, f: a.tofile(f)
else:
write = _array_to_file_like
# Implements a workaround for a bug deep in OSX's stdlib file writing
# functions; on 64-bit OSX it is not possible to correctly write a number
# of bytes greater than 2 ** 32 and divisible by 4096 (or possibly 8192--
# whatever the default blocksize for the filesystem is).
# This issue should have a workaround in Numpy too, but hasn't been
# implemented there yet: https://github.com/astropy/astropy/issues/839
#
# Apparently Windows has its own fwrite bug:
# https://github.com/numpy/numpy/issues/2256
if (sys.platform == 'darwin' and arr.nbytes >= _OSX_WRITE_LIMIT + 1 and
arr.nbytes % 4096 == 0):
# chunksize is a count of elements in the array, not bytes
chunksize = _OSX_WRITE_LIMIT // arr.itemsize
elif sys.platform.startswith('win'):
chunksize = _WIN_WRITE_LIMIT // arr.itemsize
else:
# Just pass the whole array to the write routine
> return write(arr, outfile)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/util.py:675:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
arr = array([0, 0, 0, ..., 0, 0, 0], dtype=uint8), fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0xe489710>>
def _array_to_file_like(arr, fileobj):
"""
Write a `~numpy.ndarray` to a file-like object (which is not supported by
`numpy.ndarray.tofile`).
"""
if arr.flags.contiguous:
# It suffices to just pass the underlying buffer directly to the
# fileobj's write (assuming it supports the buffer interface, which
# unfortunately there's no simple way to check)
> fileobj.write(arr.data)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/util.py:696:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.file._File <_io.BytesIO object at 0xe489710>>
string = <read-write buffer for 0xdfaa560, size 2880, offset 0 at 0xea7fbf0>
def write(self, string):
if hasattr(self.__file, 'write'):
> _write_string(self.__file, string)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/file.py:268:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
f = <_io.BytesIO object at 0xe489710>, s = <read-write buffer for 0xdfaa560, size 2880, offset 0 at 0xea7fbf0>
def _write_string(f, s):
"""
Write a string to a file, encoding to ASCII if the file is open in binary
mode, or decoding if the file is open in text mode.
"""
# Assume if the file object doesn't have a specific mode, that the mode is
# binary
binmode = fileobj_is_binary(f)
if binmode and isinstance(s, text_type):
s = encode_ascii(s)
elif not binmode and not isinstance(f, text_type):
s = decode_ascii(s)
elif isinstance(f, StringIO) and isinstance(s, np.ndarray):
# Workaround for StringIO/ndarray incompatibility
s = s.data
> f.write(s)
E TypeError: 'buffer' does not have the buffer interface
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/util.py:732: TypeError
_______________________________________________________________ test_dist ________________________________________________________________
def test_dist():
with get_pkg_data_fileobj(
os.path.join("data", "dist.fits"), encoding='binary') as test_file:
hdulist = fits.open(test_file)
wcs1 = wcs.WCS(hdulist[0].header, hdulist)
assert wcs1.det2im2 is not None
> s = cPickle.dumps(wcs1)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/wcs/tests/test_pickle.py:29:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.wcs.wcs.WCS object at 0x12db7440>
def __reduce__(self):
"""
Support pickling of WCS objects. This is done by serializing
to an in-memory FITS file and dumping that as a string.
"""
hdulist = self.to_fits(relax=True)
buffer = io.BytesIO()
> hdulist.writeto(buffer)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/wcs/wcs.py:2579:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x1258b5d0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x12440f90>]
fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0x12dba4d0>>, output_verify = 'exception', clobber = False, checksum = False
def writeto(self, fileobj, output_verify='exception', clobber=False,
checksum=False):
"""
Write the `HDUList` to a new file.
Parameters
----------
fileobj : file path, file object or file-like object
File to write to. If a file object, must be opened in a
writeable mode.
output_verify : str
Output verification option. Must be one of ``"fix"``,
``"silentfix"``, ``"ignore"``, ``"warn"``, or
``"exception"``. May also be any combination of ``"fix"`` or
``"silentfix"`` with ``"+ignore"``, ``+warn``, or ``+exception"
(e.g. ``"fix+warn"``). See :ref:`verify` for more info.
clobber : bool
When `True`, overwrite the output file if exists.
checksum : bool
When `True` adds both ``DATASUM`` and ``CHECKSUM`` cards
to the headers of all HDU's written to the file.
"""
if (len(self) == 0):
warnings.warn("There is nothing to write.", AstropyUserWarning)
return
self.verify(option=output_verify)
# make sure the EXTEND keyword is there if there is extension
self.update_extend()
# make note of whether the input file object is already open, in which
# case we should not close it after writing (that should be the job
# of the caller)
closed = isinstance(fileobj, string_types) or fileobj_closed(fileobj)
# writeto is only for writing a new file from scratch, so the most
# sensible mode to require is 'ostream'. This can accept an open
# file object that's open to write only, or in append/update modes
# but only if the file doesn't exist.
fileobj = _File(fileobj, mode='ostream', clobber=clobber)
hdulist = self.fromfile(fileobj)
for hdu in self:
hdu._prewriteto(checksum=checksum)
try:
> hdu._writeto(hdulist.__file)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/hdulist.py:682:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.hdu.image.ImageHDU object at 0x12440f90>
fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0x12dba4d0>>, inplace = False, copy = False
def _writeto(self, fileobj, inplace=False, copy=False):
# For now fileobj is assumed to be a _File object
if not inplace or self._new:
header_offset, _ = self._writeheader(fileobj)
> data_offset, data_size = self._writedata(fileobj)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/base.py:698:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.hdu.image.ImageHDU object at 0x12440f90>
fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0x12dba4d0>>
def _writedata(self, fileobj):
# TODO: A lot of the simulateonly stuff should be moved back into the
# _File class--basically it should turn write and flush into a noop
offset = 0
size = 0
if not fileobj.simulateonly:
fileobj.flush()
try:
offset = fileobj.tell()
except IOError:
offset = 0
if self._data_loaded or self._data_needs_rescale:
if self.data is not None:
> size += self._writedata_internal(fileobj)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/base.py:635:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.hdu.image.ImageHDU object at 0x12440f90>
fileobj = <astropy.io.fits.file._File <_io.BytesIO object at 0x12dba4d0>>
def _writedata_internal(self, fileobj):
size = 0
if self.data is not None:
# Based on the system type, determine the byteorders that
# would need to be swapped to get to big-endian output
if sys.byteorder == 'little':
swap_types = ('<', '=')
else:
swap_types = ('<',)
# deal with unsigned integer 16, 32 and 64 data
if _is_pseudo_unsigned(self.data.dtype):
# Convert the unsigned array to signed
output = np.array(
self.data - _unsigned_zero(self.data.dtype),
dtype='>i%d' % self.data.dtype.itemsize)
should_swap = False
else:
output = self.data
byteorder = output.dtype.str[0]
should_swap = (byteorder in swap_types)
if not fileobj.simulateonly:
if should_swap:
output.byteswap(True)
try:
> fileobj.writearray(output)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/hdu/image.py:521:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <astropy.io.fits.file._File <_io.BytesIO object at 0x12dba4d0>>
array = array([[ -1.27305422e-04, -2.63464113e-04, -5.10875077e-04, ...,
2.40933063e-04, 1.06801039e-04, -3.66208042e-08]], dtype=float32)
def writearray(self, array):
"""
Similar to file.write(), but writes a numpy array instead of a string.
Also like file.write(), a flush() or close() may be needed before
the file on disk reflects the data written.
"""
if hasattr(self.__file, 'write'):
> _array_to_file(array, self.__file)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/file.py:279:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
arr = array([[ -1.27305422e-04, -2.63464113e-04, -5.10875077e-04, ...,
2.40933063e-04, 1.06801039e-04, -3.66208042e-08]], dtype=float32)
outfile = <_io.BytesIO object at 0x12dba4d0>
def _array_to_file(arr, outfile):
"""
Write a numpy array to a file or a file-like object.
Parameters
----------
arr : `~numpy.ndarray`
The Numpy array to write.
outfile : file-like
A file-like object such as a Python file object, an `io.BytesIO`, or
anything else with a ``write`` method. The file object must support
the buffer interface in its ``write``.
If writing directly to an on-disk file this delegates directly to
`ndarray.tofile`. Otherwise a slower Python implementation is used.
"""
if isfile(outfile):
write = lambda a, f: a.tofile(f)
else:
write = _array_to_file_like
# Implements a workaround for a bug deep in OSX's stdlib file writing
# functions; on 64-bit OSX it is not possible to correctly write a number
# of bytes greater than 2 ** 32 and divisible by 4096 (or possibly 8192--
# whatever the default blocksize for the filesystem is).
# This issue should have a workaround in Numpy too, but hasn't been
# implemented there yet: https://github.com/astropy/astropy/issues/839
#
# Apparently Windows has its own fwrite bug:
# https://github.com/numpy/numpy/issues/2256
if (sys.platform == 'darwin' and arr.nbytes >= _OSX_WRITE_LIMIT + 1 and
arr.nbytes % 4096 == 0):
# chunksize is a count of elements in the array, not bytes
chunksize = _OSX_WRITE_LIMIT // arr.itemsize
elif sys.platform.startswith('win'):
chunksize = _WIN_WRITE_LIMIT // arr.itemsize
else:
# Just pass the whole array to the write routine
> return write(arr, outfile)
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/util.py:675:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
arr = array([[ -1.27305422e-04, -2.63464113e-04, -5.10875077e-04, ...,
2.40933063e-04, 1.06801039e-04, -3.66208042e-08]], dtype=float32)
fileobj = <_io.BytesIO object at 0x12dba4d0>
def _array_to_file_like(arr, fileobj):
"""
Write a `~numpy.ndarray` to a file-like object (which is not supported by
`numpy.ndarray.tofile`).
"""
if arr.flags.contiguous:
# It suffices to just pass the underlying buffer directly to the
# fileobj's write (assuming it supports the buffer interface, which
# unfortunately there's no simple way to check)
> fileobj.write(arr.data)
E TypeError: 'buffer' does not have the buffer interface
/proj/sot/ska/dev/arch/x86_64-linux_CentOS-5/lib/python2.7/site-packages/astropy/io/fits/util.py:696: TypeError
============================== 6 failed, 8252 passed, 167 skipped, 46 xfailed, 3 xpassed in 371.75 seconds ===============================
1
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment