Created
December 18, 2019 11:13
-
-
Save astrofrog/a3edb96f29bc34b4dfb2cf596c9897ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
============================= test session starts ============================== | |
platform linux -- Python 3.6.9[pypy-7.2.0-final], pytest-5.3.2, py-1.8.0, pluggy-0.13.1 | |
Running tests with Astropy version 4.0. | |
Running tests in pypy/site-packages/astropy. | |
Date: 2019-12-18T11:05:26 | |
Platform: Linux-5.3.0-24-generic-x86_64-with-debian-buster-sid | |
Executable: /home/tom/pypy/bin/pypy | |
Full Python Version: | |
3.6.9 (5da45ced70e515f94686be0df47c59abd1348ebc, Oct 17 2019, 22:59:56) | |
[PyPy 7.2.0 with GCC 8.2.0] | |
encodings: sys: utf-8, locale: UTF-8, filesystem: utf-8 | |
byteorder: little | |
float info: dig: 15, mant_dig: 15 | |
Package versions: | |
Numpy: 1.17.4 | |
Scipy: not available | |
Matplotlib: not available | |
h5py: not available | |
Pandas: not available | |
Cython: not available | |
Scikit-image: not available | |
asdf: not available | |
astropy-helpers: 4.0 | |
Using Astropy options: remote_data: none. | |
rootdir: /home/tom | |
plugins: hypothesis-4.55.2, remotedata-0.3.2, openfiles-0.4.0, doctestplus-0.5.0, astropy-header-0.1.1, arraydiff-0.3 | |
collected 13614 items / 26 skipped / 13588 selected | |
pypy/site-packages/astropy/_erfa/tests/test_erfa.py .................... [ 0%] | |
[ 0%] | |
pypy/site-packages/astropy/config/tests/test_configs.py ................ [ 0%] | |
[ 0%] | |
pypy/site-packages/astropy/constants/tests/test_constant.py ........ [ 0%] | |
pypy/site-packages/astropy/constants/tests/test_pickle.py ......... [ 0%] | |
pypy/site-packages/astropy/constants/tests/test_prior_version.py ....... [ 0%] | |
... [ 0%] | |
pypy/site-packages/astropy/constants/tests/test_sciencestate.py .. [ 0%] | |
pypy/site-packages/astropy/convolution/tests/test_convolve.py .......... [ 0%] | |
........................................................................ [ 1%] | |
........................................................................ [ 1%] | |
........................................................................ [ 2%] | |
........................................................................ [ 2%] | |
......................................................x.x.x.x.x.x.x.x... [ 3%] | |
........................................................................ [ 3%] | |
..........................ss.............. [ 4%] | |
pypy/site-packages/astropy/convolution/tests/test_convolve_fft.py ...... [ 4%] | |
........................................................................ [ 4%] | |
........................................................................ [ 5%] | |
........................................................................ [ 5%] | |
........................................................................ [ 6%] | |
........................................................................ [ 6%] | |
........................................................................ [ 7%] | |
...................................................... [ 7%] | |
pypy/site-packages/astropy/convolution/tests/test_convolve_kernels.py .. [ 7%] | |
........................................................................ [ 8%] | |
...................................... [ 8%] | |
pypy/site-packages/astropy/convolution/tests/test_convolve_models.py sss [ 8%] | |
sss....ss [ 8%] | |
pypy/site-packages/astropy/convolution/tests/test_convolve_nddata.py ... [ 8%] | |
[ 8%] | |
pypy/site-packages/astropy/convolution/tests/test_discretize.py ...s.... [ 8%] | |
.......s........sss........ [ 8%] | |
pypy/site-packages/astropy/convolution/tests/test_kernel_class.py ssssss [ 8%] | |
ss................................ssss.................................. [ 9%] | |
..ssss.................................................................. [ 9%] | |
............ssss............... [ 10%] | |
pypy/site-packages/astropy/convolution/tests/test_pickle.py .xx.xx.xx [ 10%] | |
pypy/site-packages/astropy/coordinates/tests/test_angles.py ............ [ 10%] | |
............................... [ 10%] | |
pypy/site-packages/astropy/coordinates/tests/test_angular_separation.py . [ 10%] | |
... [ 10%] | |
pypy/site-packages/astropy/coordinates/tests/test_api_ape5.py ....s [ 10%] | |
pypy/site-packages/astropy/coordinates/tests/test_arrays.py ............ [ 10%] | |
. [ 10%] | |
pypy/site-packages/astropy/coordinates/tests/test_atc_replacements.py .. [ 10%] | |
.. [ 10%] | |
pypy/site-packages/astropy/coordinates/tests/test_celestial_transformations.py . [ 10%] | |
...........ss.. [ 10%] | |
pypy/site-packages/astropy/coordinates/tests/test_distance.py .s........ [ 10%] | |
. [ 10%] | |
pypy/site-packages/astropy/coordinates/tests/test_earth.py ............. [ 11%] | |
.s.. [ 11%] | |
pypy/site-packages/astropy/coordinates/tests/test_finite_difference_velocities.py . [ 11%] | |
.....s..xx [ 11%] | |
pypy/site-packages/astropy/coordinates/tests/test_formatting.py ........ [ 11%] | |
.. [ 11%] | |
pypy/site-packages/astropy/coordinates/tests/test_frames.py ............ [ 11%] | |
................s................ [ 11%] | |
pypy/site-packages/astropy/coordinates/tests/test_frames_with_velocity.py . [ 11%] | |
............................................... [ 11%] | |
pypy/site-packages/astropy/coordinates/tests/test_funcs.py ..... [ 11%] | |
pypy/site-packages/astropy/coordinates/tests/test_iau_fullstack.py sssss [ 11%] | |
ssssssssssssssssssssssssssssssssssssssssssssss. [ 12%] | |
pypy/site-packages/astropy/coordinates/tests/test_intermediate_transformations.py . [ 12%] | |
....sssssssssssssssssssssssssssssss..........ssssssssss.ss [ 12%] | |
pypy/site-packages/astropy/coordinates/tests/test_matching.py ssssssssss [ 12%] | |
sss [ 12%] | |
pypy/site-packages/astropy/coordinates/tests/test_matrix_utilities.py .. [ 12%] | |
[ 12%] | |
pypy/site-packages/astropy/coordinates/tests/test_name_resolve.py s.ss [ 12%] | |
pypy/site-packages/astropy/coordinates/tests/test_pickle.py ...xxx.x..xx [ 12%] | |
x.x..xxx.x. [ 13%] | |
pypy/site-packages/astropy/coordinates/tests/test_regression.py .ss.ss.. [ 13%] | |
..s.sss.s.ssss...s.... [ 13%] | |
pypy/site-packages/astropy/coordinates/tests/test_representation.py .... [ 13%] | |
........................................................................ [ 13%] | |
....s.................. [ 14%] | |
pypy/site-packages/astropy/coordinates/tests/test_representation_arithmetic.py . [ 14%] | |
........................................................................ [ 14%] | |
................ [ 14%] | |
pypy/site-packages/astropy/coordinates/tests/test_representation_methods.py . [ 14%] | |
........... [ 14%] | |
pypy/site-packages/astropy/coordinates/tests/test_shape_manipulation.py s [ 14%] | |
ssssssss [ 14%] | |
pypy/site-packages/astropy/coordinates/tests/test_sites.py .ss.s... [ 14%] | |
pypy/site-packages/astropy/coordinates/tests/test_sky_coord.py ......... [ 14%] | |
........................................................................ [ 15%] | |
........................................................................ [ 15%] | |
........................................................................ [ 16%] | |
............................................s........................... [ 17%] | |
........................................................................ [ 17%] | |
..........x........s......s............ [ 17%] | |
pypy/site-packages/astropy/coordinates/tests/test_sky_coord_velocities.py . [ 17%] | |
........xs......s...x.xs......s... [ 18%] | |
pypy/site-packages/astropy/coordinates/tests/test_skyoffset_transformations.py . [ 18%] | |
..........s................. [ 18%] | |
pypy/site-packages/astropy/coordinates/tests/test_solar_system.py s....s [ 18%] | |
sssssssssssss....ssssssss [ 18%] | |
pypy/site-packages/astropy/coordinates/tests/test_transformations.py ... [ 18%] | |
.......................s.... [ 18%] | |
pypy/site-packages/astropy/coordinates/tests/test_unit_representation.py s [ 18%] | |
[ 18%] | |
pypy/site-packages/astropy/coordinates/tests/test_velocity_corrs.py ssss [ 18%] | |
ss [ 18%] | |
pypy/site-packages/astropy/coordinates/tests/accuracy/test_altaz_icrs.py s [ 18%] | |
sss [ 18%] | |
pypy/site-packages/astropy/coordinates/tests/accuracy/test_ecliptic.py . [ 18%] | |
........ [ 18%] | |
pypy/site-packages/astropy/coordinates/tests/accuracy/test_fk4_no_e_fk4.py . [ 18%] | |
[ 18%] | |
pypy/site-packages/astropy/coordinates/tests/accuracy/test_fk4_no_e_fk5.py . [ 18%] | |
[ 18%] | |
pypy/site-packages/astropy/coordinates/tests/accuracy/test_galactic_fk4.py . [ 18%] | |
[ 18%] | |
pypy/site-packages/astropy/coordinates/tests/accuracy/test_icrs_fk5.py . [ 18%] | |
[ 18%] | |
pypy/site-packages/astropy/cosmology/tests/test_cosmology.py ..sss..s.ss [ 19%] | |
ssssss.ssssss.sssssssssssssssss [ 19%] | |
pypy/site-packages/astropy/cosmology/tests/test_pickle.py ... [ 19%] | |
pypy/site-packages/astropy/io/ascii/tests/test_c_reader.py ............. [ 19%] | |
................x..............................x.......x.x.............. [ 19%] | |
...ssssss..ssss..ss....ssssss...................... [ 20%] | |
pypy/site-packages/astropy/io/ascii/tests/test_cds_header_from_readme.py . [ 20%] | |
.... [ 20%] | |
pypy/site-packages/astropy/io/ascii/tests/test_compressed.py ....... [ 20%] | |
pypy/site-packages/astropy/io/ascii/tests/test_connect.py .............s [ 20%] | |
s........s [ 20%] | |
pypy/site-packages/astropy/io/ascii/tests/test_ecsv.py sssssssssssssssss [ 20%] | |
sssssssssssssssssssss.ssss [ 20%] | |
pypy/site-packages/astropy/io/ascii/tests/test_fixedwidth.py ........... [ 20%] | |
..................... [ 21%] | |
pypy/site-packages/astropy/io/ascii/tests/test_html.py s.ssssss.ssss.s.s [ 21%] | |
ss.....s [ 21%] | |
pypy/site-packages/astropy/io/ascii/tests/test_ipac_definitions.py ..... [ 21%] | |
................ [ 21%] | |
pypy/site-packages/astropy/io/ascii/tests/test_read.py ................. [ 21%] | |
........................................................................ [ 22%] | |
.......................s................ [ 22%] | |
pypy/site-packages/astropy/io/ascii/tests/test_rst.py ......... [ 22%] | |
pypy/site-packages/astropy/io/ascii/tests/test_types.py ... [ 22%] | |
pypy/site-packages/astropy/io/ascii/tests/test_write.py ................ [ 22%] | |
........................................................................ [ 23%] | |
. [ 23%] | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py FFFFFFFFFFFF.F [ 23%] | |
F.F.FFF [ 23%] | |
pypy/site-packages/astropy/io/fits/tests/test_compression_failures.py .. [ 23%] | |
................................... [ 23%] | |
pypy/site-packages/astropy/io/fits/tests/test_connect.py .......s....... [ 23%] | |
.F.F..................................................................FF [ 24%] | |
..sssssssssssssssssssssss..ssss [ 24%] | |
pypy/site-packages/astropy/io/fits/tests/test_convenience.py F.......... [ 24%] | |
......FFFF....F [ 24%] | |
pypy/site-packages/astropy/io/fits/tests/test_core.py ...FF.F..F........ [ 24%] | |
..FF..FFF....s.......................F.FFFF.FF....F...FF [ 25%] | |
pypy/site-packages/astropy/io/fits/tests/test_diff.py .................. [ 25%] | |
...F.........F........ [ 25%] | |
pypy/site-packages/astropy/io/fits/tests/test_division.py F.... [ 25%] | |
pypy/site-packages/astropy/io/fits/tests/test_fitscheck.py ..F..F [ 25%] | |
pypy/site-packages/astropy/io/fits/tests/test_fitsdiff.py ...FFFFFFF.FFF [ 25%] | |
F. [ 25%] | |
pypy/site-packages/astropy/io/fits/tests/test_fitsheader.py ....... [ 25%] | |
pypy/site-packages/astropy/io/fits/tests/test_fitsinfo.py .. [ 25%] | |
pypy/site-packages/astropy/io/fits/tests/test_fitstime.py .............. [ 25%] | |
....... [ 25%] | |
pypy/site-packages/astropy/io/fits/tests/test_groups.py F.FFFFF. [ 25%] | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py .FF...F.FF...F. [ 26%] | |
FF..FF.......F.....FFFFFFFFFF......... [ 26%] | |
pypy/site-packages/astropy/io/fits/tests/test_header.py ................ [ 26%] | |
..F..................................................................... [ 26%] | |
..........................F....................................... [ 27%] | |
pypy/site-packages/astropy/io/fits/tests/test_image.py ......FF.F..FFFFF [ 27%] | |
FFF.FFFFFFFFFFFFF...FFFFFFFFFFFFs.FF..FFFFF........F..F.FFFFFFFFFFFF.F.F [ 28%] | |
[ 28%] | |
pypy/site-packages/astropy/io/fits/tests/test_nonstandard.py FFF [ 28%] | |
pypy/site-packages/astropy/io/fits/tests/test_structured.py F [ 28%] | |
pypy/site-packages/astropy/io/fits/tests/test_table.py .FFFFFFFFFFF.F.FF [ 28%] | |
F..FFF.....FFFFFFFFFFFFFFF...F.FFF.FFFFF.FFFssFFFF.FFFFFF.F...F......... [ 28%] | |
.F. [ 28%] | |
pypy/site-packages/astropy/io/fits/tests/test_uint.py FFFFFFFFF [ 28%] | |
pypy/site-packages/astropy/io/fits/tests/test_util.py ...s..... [ 28%] | |
pypy/site-packages/astropy/io/misc/tests/test_hdf5.py ssssssssssssssssss [ 29%] | |
sssssssssssssssssssssssssssssssssssssssssssssssssssssss [ 29%] | |
pypy/site-packages/astropy/io/misc/tests/test_pickle_helpers.py .... [ 29%] | |
pypy/site-packages/astropy/io/misc/tests/test_yaml.py ssssssssssssssssss [ 29%] | |
ssssssssssssss [ 29%] | |
pypy/site-packages/astropy/io/tests/test_registry.py ................... [ 29%] | |
................ [ 30%] | |
pypy/site-packages/astropy/io/tests/test_registry_help.py ......... [ 30%] | |
pypy/site-packages/astropy/io/votable/tests/converter_test.py .......... [ 30%] | |
............. [ 30%] | |
pypy/site-packages/astropy/io/votable/tests/exception_test.py .. [ 30%] | |
pypy/site-packages/astropy/io/votable/tests/resource_test.py . [ 30%] | |
pypy/site-packages/astropy/io/votable/tests/table_test.py .............. [ 30%] | |
........ [ 30%] | |
pypy/site-packages/astropy/io/votable/tests/tree_test.py ... [ 30%] | |
pypy/site-packages/astropy/io/votable/tests/ucd_test.py ..... [ 30%] | |
pypy/site-packages/astropy/io/votable/tests/util_test.py ........... [ 30%] | |
pypy/site-packages/astropy/io/votable/tests/vo_test.py ................. [ 30%] | |
........................................................................ [ 31%] | |
..................................................................F..... [ 31%] | |
..... [ 31%] | |
pypy/site-packages/astropy/modeling/tests/test_blackbody.py ..ss.... [ 31%] | |
pypy/site-packages/astropy/modeling/tests/test_compound.py ............. [ 31%] | |
...........................s.s...... [ 32%] | |
pypy/site-packages/astropy/modeling/tests/test_constraints.py ssssssss.. [ 32%] | |
.........ssss.. [ 32%] | |
pypy/site-packages/astropy/modeling/tests/test_core.py ...............s. [ 32%] | |
........ [ 32%] | |
pypy/site-packages/astropy/modeling/tests/test_fitters.py ..s..ssss..... [ 32%] | |
....sssssssss....ss..sssssssssss [ 32%] | |
pypy/site-packages/astropy/modeling/tests/test_functional_models.py .... [ 32%] | |
..........s....ss.. [ 33%] | |
pypy/site-packages/astropy/modeling/tests/test_input.py ...............s [ 33%] | |
sss...................................ssss.......... [ 33%] | |
pypy/site-packages/astropy/modeling/tests/test_mappings.py ......s.. [ 33%] | |
pypy/site-packages/astropy/modeling/tests/test_math_func.py . [ 33%] | |
pypy/site-packages/astropy/modeling/tests/test_model_sets.py ........ [ 33%] | |
pypy/site-packages/astropy/modeling/tests/test_models.py s.............. [ 33%] | |
s....................s...........ss..ss.s.ss.s.sssssssssssssssssssssssss [ 34%] | |
ssssssssssssssssssssssss........s..s........s..s.s..sss.s.ssssssssssssss [ 34%] | |
sssssssssss....sss.sss. [ 35%] | |
pypy/site-packages/astropy/modeling/tests/test_models_quantities.py .s.. [ 35%] | |
................s.s......s..................s.s......s.................. [ 35%] | |
s.s......s..................s.s......s..................s.s.....ssssssss [ 36%] | |
ssssssssssssssssssss [ 36%] | |
pypy/site-packages/astropy/modeling/tests/test_parameters.py ........... [ 36%] | |
.......................................... [ 36%] | |
pypy/site-packages/astropy/modeling/tests/test_physical_models.py .....s [ 36%] | |
... [ 36%] | |
pypy/site-packages/astropy/modeling/tests/test_polynomial.py sssssssssss [ 36%] | |
ssssssssssssssssssssssssss.........s [ 37%] | |
pypy/site-packages/astropy/modeling/tests/test_projections.py .......... [ 37%] | |
........................................................................ [ 37%] | |
.......................................................... [ 38%] | |
pypy/site-packages/astropy/modeling/tests/test_quantities_evaluation.py . [ 38%] | |
................... [ 38%] | |
pypy/site-packages/astropy/modeling/tests/test_quantities_fitting.py sss [ 38%] | |
ssssss [ 38%] | |
pypy/site-packages/astropy/modeling/tests/test_quantities_model.py ..... [ 38%] | |
........................................................................ [ 38%] | |
........................................................................ [ 39%] | |
......................................... [ 39%] | |
pypy/site-packages/astropy/modeling/tests/test_quantities_parameters.py . [ 39%] | |
............ [ 39%] | |
pypy/site-packages/astropy/modeling/tests/test_quantities_rotations.py . [ 39%] | |
.............. [ 39%] | |
pypy/site-packages/astropy/modeling/tests/test_rotations.py ............ [ 40%] | |
.......... [ 40%] | |
pypy/site-packages/astropy/modeling/tests/test_separable.py .......... [ 40%] | |
pypy/site-packages/astropy/modeling/tests/test_utils.py ... [ 40%] | |
pypy/site-packages/astropy/nddata/mixins/tests/test_ndarithmetic.py .... [ 40%] | |
........................................................................ [ 40%] | |
........................................................................ [ 41%] | |
............................. [ 41%] | |
pypy/site-packages/astropy/nddata/mixins/tests/test_ndio.py . [ 41%] | |
pypy/site-packages/astropy/nddata/mixins/tests/test_ndslicing.py ....... [ 41%] | |
... [ 41%] | |
pypy/site-packages/astropy/nddata/tests/test_bitmask.py ................ [ 41%] | |
.................................................... [ 42%] | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py ......FFFFFFF..F [ 42%] | |
..F...........................................FFFFF.F......F....FFFFFFFF [ 42%] | |
FF.F..F. [ 42%] | |
pypy/site-packages/astropy/nddata/tests/test_compat.py ................. [ 42%] | |
[ 42%] | |
pypy/site-packages/astropy/nddata/tests/test_decorators.py ............. [ 42%] | |
............... [ 43%] | |
pypy/site-packages/astropy/nddata/tests/test_flag_collection.py ........ [ 43%] | |
.. [ 43%] | |
pypy/site-packages/astropy/nddata/tests/test_nddata.py ................. [ 43%] | |
..F..................... [ 43%] | |
pypy/site-packages/astropy/nddata/tests/test_nddata_base.py . [ 43%] | |
pypy/site-packages/astropy/nddata/tests/test_nduncertainty.py .......... [ 43%] | |
................................................................. [ 44%] | |
pypy/site-packages/astropy/nddata/tests/test_utils.py .................. [ 44%] | |
..............sssssssssssss................. [ 44%] | |
pypy/site-packages/astropy/samp/tests/test_client.py .... [ 44%] | |
pypy/site-packages/astropy/samp/tests/test_errors.py ... [ 44%] | |
pypy/site-packages/astropy/samp/tests/test_hub.py ... [ 44%] | |
pypy/site-packages/astropy/samp/tests/test_hub_proxy.py ..... [ 44%] | |
pypy/site-packages/astropy/samp/tests/test_hub_script.py . [ 44%] | |
pypy/site-packages/astropy/samp/tests/test_standard_profile.py . [ 44%] | |
pypy/site-packages/astropy/samp/tests/test_web_profile.py .. [ 44%] | |
pypy/site-packages/astropy/stats/tests/test_bayesian_blocks.py ........ [ 44%] | |
pypy/site-packages/astropy/stats/tests/test_biweight.py ................ [ 44%] | |
................ [ 44%] | |
pypy/site-packages/astropy/stats/tests/test_circstats.py ..s....s. [ 44%] | |
pypy/site-packages/astropy/stats/tests/test_funcs.py ......ss...s....... [ 45%] | |
....ssss.s..sssssssssssssss.sssssssssssssssssssssssssssssssss [ 45%] | |
pypy/site-packages/astropy/stats/tests/test_histogram.py ..ss..........s [ 45%] | |
.. [ 45%] | |
pypy/site-packages/astropy/stats/tests/test_info_theory.py .... [ 45%] | |
pypy/site-packages/astropy/stats/tests/test_jackknife.py .ss. [ 45%] | |
pypy/site-packages/astropy/stats/tests/test_sigma_clipping.py .s........ [ 45%] | |
...... [ 45%] | |
pypy/site-packages/astropy/stats/tests/test_spatial.py ............ [ 45%] | |
pypy/site-packages/astropy/table/tests/test_array.py ... [ 45%] | |
pypy/site-packages/astropy/table/tests/test_bst.py ....... [ 46%] | |
pypy/site-packages/astropy/table/tests/test_column.py .................. [ 46%] | |
........................................................................ [ 46%] | |
.............................. [ 46%] | |
pypy/site-packages/astropy/table/tests/test_groups.py .................. [ 47%] | |
..................... [ 47%] | |
pypy/site-packages/astropy/table/tests/test_index.py ................... [ 47%] | |
........................................................................ [ 47%] | |
........................................................................ [ 48%] | |
........................................................................ [ 48%] | |
........FFF...............FFF........................................... [ 49%] | |
........................................................................ [ 49%] | |
........................................................................ [ 50%] | |
..................................................................... [ 51%] | |
pypy/site-packages/astropy/table/tests/test_info.py .............F.. [ 51%] | |
pypy/site-packages/astropy/table/tests/test_init_table.py .............. [ 51%] | |
........................................................................ [ 51%] | |
........................................................................ [ 52%] | |
.... [ 52%] | |
pypy/site-packages/astropy/table/tests/test_item_access.py ............. [ 52%] | |
......................... [ 52%] | |
pypy/site-packages/astropy/table/tests/test_jsviewer.py .s.s [ 52%] | |
pypy/site-packages/astropy/table/tests/test_masked.py .................. [ 52%] | |
........................ [ 52%] | |
pypy/site-packages/astropy/table/tests/test_mixin.py ................... [ 53%] | |
...............ss...sss.s............................................... [ 53%] | |
................... [ 53%] | |
pypy/site-packages/astropy/table/tests/test_np_utils.py . [ 53%] | |
pypy/site-packages/astropy/table/tests/test_operations.py .......x...x.x [ 53%] | |
.x............x.....x...................................x...x...x....... [ 54%] | |
......x........................x.......................... [ 54%] | |
pypy/site-packages/astropy/table/tests/test_pickle.py .................. [ 54%] | |
............ [ 55%] | |
pypy/site-packages/astropy/table/tests/test_pprint.py .................. [ 55%] | |
......................................... [ 55%] | |
pypy/site-packages/astropy/table/tests/test_row.py ..................... [ 55%] | |
................... [ 55%] | |
pypy/site-packages/astropy/table/tests/test_showtable.py ............ [ 55%] | |
pypy/site-packages/astropy/table/tests/test_subclass.py .. [ 55%] | |
pypy/site-packages/astropy/table/tests/test_table.py ................... [ 56%] | |
........................................................................ [ 56%] | |
........................................................................ [ 57%] | |
........................................................................ [ 57%] | |
........................................................................ [ 58%] | |
..........................FFF.......x...........................sssssss. [ 58%] | |
......................FFF.............. [ 58%] | |
pypy/site-packages/astropy/tests/test_logger.py ............s........... [ 59%] | |
........ [ 59%] | |
pypy/site-packages/astropy/tests/tests/test_imports.py s. [ 59%] | |
pypy/site-packages/astropy/tests/tests/test_quantity_helpers.py . [ 59%] | |
pypy/site-packages/astropy/tests/tests/test_run_tests.py ... [ 59%] | |
pypy/site-packages/astropy/tests/tests/test_runner.py ...... [ 59%] | |
pypy/site-packages/astropy/time/tests/test_basic.py .................... [ 59%] | |
........................................................................ [ 59%] | |
...........s..........s................................................. [ 60%] | |
..... [ 60%] | |
pypy/site-packages/astropy/time/tests/test_comparisons.py .... [ 60%] | |
pypy/site-packages/astropy/time/tests/test_corrs.py ...s [ 60%] | |
pypy/site-packages/astropy/time/tests/test_custom_formats.py ........... [ 60%] | |
....................... [ 60%] | |
pypy/site-packages/astropy/time/tests/test_delta.py .........F.......... [ 60%] | |
.......................................................................F [ 61%] | |
FF. [ 61%] | |
pypy/site-packages/astropy/time/tests/test_guess.py .... [ 61%] | |
pypy/site-packages/astropy/time/tests/test_mask.py ........ss [ 61%] | |
pypy/site-packages/astropy/time/tests/test_methods.py .................. [ 61%] | |
................................x....................................... [ 62%] | |
................x...... [ 62%] | |
pypy/site-packages/astropy/time/tests/test_pickle.py . [ 62%] | |
pypy/site-packages/astropy/time/tests/test_precision.py ................ [ 62%] | |
.. [ 62%] | |
pypy/site-packages/astropy/time/tests/test_quantity_interaction.py ..... [ 62%] | |
................. [ 62%] | |
pypy/site-packages/astropy/time/tests/test_sidereal.py ................. [ 62%] | |
.. [ 62%] | |
pypy/site-packages/astropy/time/tests/test_update_leap_seconds.py .ss... [ 62%] | |
[ 62%] | |
pypy/site-packages/astropy/time/tests/test_ut1.py s..ss. [ 62%] | |
pypy/site-packages/astropy/timeseries/io/tests/test_kepler.py .....ss [ 63%] | |
pypy/site-packages/astropy/timeseries/periodograms/bls/tests/test_bls.py . [ 63%] | |
...................................................... [ 63%] | |
pypy/site-packages/astropy/timeseries/periodograms/lombscargle/implementations/tests/test_mle.py . [ 63%] | |
....................... [ 63%] | |
pypy/site-packages/astropy/timeseries/periodograms/lombscargle/implementations/tests/test_utils.py . [ 63%] | |
............................................ [ 63%] | |
pypy/site-packages/astropy/timeseries/periodograms/lombscargle/tests/test_lombscargle.py . [ 63%] | |
........................................................................ [ 64%] | |
........................................................................ [ 65%] | |
........................................................................ [ 65%] | |
........................................................................ [ 66%] | |
........................................................................ [ 66%] | |
........................................................................ [ 67%] | |
........................................................................ [ 67%] | |
........................................................................ [ 68%] | |
........................................................................ [ 68%] | |
........................................................................ [ 69%] | |
........................................................................ [ 69%] | |
........................................................................ [ 70%] | |
........................................................................ [ 70%] | |
........................................................................ [ 71%] | |
........................................................................ [ 71%] | |
................................................................. [ 72%] | |
pypy/site-packages/astropy/timeseries/periodograms/lombscargle/tests/test_statistics.py . [ 72%] | |
...........................................ss..ss..ss..ss..ss..ss..ss..s [ 72%] | |
s..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..s [ 73%] | |
s..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..ss..s [ 73%] | |
s..ss..ss..ss..ss..s.s..s.s..s.s..s.s..s.s..s.s..s.s..s.s..s.s..s.s..s.s [ 74%] | |
..s.s..s.s..s.s..s.s..s.s..s.s..s.s..s.s..s.s.. [ 74%] | |
pypy/site-packages/astropy/timeseries/periodograms/lombscargle/tests/test_utils.py . [ 74%] | |
............... [ 74%] | |
pypy/site-packages/astropy/timeseries/tests/test_binned.py ............. [ 75%] | |
.......... [ 75%] | |
pypy/site-packages/astropy/timeseries/tests/test_common.py ............. [ 75%] | |
........... [ 75%] | |
pypy/site-packages/astropy/timeseries/tests/test_downsample.py ... [ 75%] | |
pypy/site-packages/astropy/timeseries/tests/test_sampled.py ............ [ 75%] | |
....s...ss... [ 75%] | |
pypy/site-packages/astropy/uncertainty/tests/test_distribution.py ...... [ 75%] | |
.......s......ss............... [ 75%] | |
pypy/site-packages/astropy/units/tests/test_deprecated.py .. [ 75%] | |
pypy/site-packages/astropy/units/tests/test_equivalencies.py ........... [ 75%] | |
....................................................... [ 76%] | |
pypy/site-packages/astropy/units/tests/test_format.py .................. [ 76%] | |
........................................................................ [ 76%] | |
........................................................................ [ 77%] | |
........................................................................ [ 77%] | |
........................................................................ [ 78%] | |
........................................................................ [ 79%] | |
........................................................................ [ 79%] | |
........................................................................ [ 80%] | |
........................................................................ [ 80%] | |
........................................................................ [ 81%] | |
.................. [ 81%] | |
pypy/site-packages/astropy/units/tests/test_logarithmic.py ............. [ 81%] | |
........................................................................ [ 81%] | |
........................................................................ [ 82%] | |
.................................................. [ 82%] | |
pypy/site-packages/astropy/units/tests/test_photometric.py .. [ 82%] | |
pypy/site-packages/astropy/units/tests/test_physical.py ........... [ 82%] | |
pypy/site-packages/astropy/units/tests/test_quantity.py ................ [ 83%] | |
............x........................................................... [ 83%] | |
[ 83%] | |
pypy/site-packages/astropy/units/tests/test_quantity_annotations.py .... [ 83%] | |
....................... [ 83%] | |
pypy/site-packages/astropy/units/tests/test_quantity_array_methods.py .. [ 83%] | |
......................................................... [ 84%] | |
pypy/site-packages/astropy/units/tests/test_quantity_decorator.py ...... [ 84%] | |
........................................................................ [ 84%] | |
........................................................................ [ 85%] | |
........................................................................ [ 85%] | |
........................................................................ [ 86%] | |
........................................................................ [ 86%] | |
........................................................................ [ 87%] | |
........................................................................ [ 87%] | |
............................................. [ 88%] | |
pypy/site-packages/astropy/units/tests/test_quantity_helpers.py .... [ 88%] | |
pypy/site-packages/astropy/units/tests/test_quantity_non_ufuncs.py ..... [ 88%] | |
........................................................................ [ 88%] | |
........................................................................ [ 89%] | |
........................................................................ [ 89%] | |
........................................ [ 90%] | |
pypy/site-packages/astropy/units/tests/test_quantity_ufuncs.py sss...... [ 90%] | |
........................................................................ [ 90%] | |
........................................................................ [ 91%] | |
.................................................. [ 91%] | |
pypy/site-packages/astropy/units/tests/test_units.py ................... [ 91%] | |
........................................................................ [ 92%] | |
........................................................................ [ 92%] | |
........................................................................ [ 93%] | |
............. [ 93%] | |
pypy/site-packages/astropy/units/tests/test_utils.py .. [ 93%] | |
pypy/site-packages/astropy/utils/iers/tests/test_iers.py .....s...ssssss [ 93%] | |
[ 93%] | |
pypy/site-packages/astropy/utils/iers/tests/test_leap_second.py ........ [ 93%] | |
.ss.....s............. [ 93%] | |
pypy/site-packages/astropy/utils/tests/test_codegen.py . [ 93%] | |
pypy/site-packages/astropy/utils/tests/test_collections.py ......... [ 93%] | |
pypy/site-packages/astropy/utils/tests/test_console.py ................. [ 94%] | |
........... [ 94%] | |
pypy/site-packages/astropy/utils/tests/test_data.py s.................ss [ 94%] | |
.s........sss...........s.....s.s.s..................................... [ 94%] | |
........................... [ 95%] | |
pypy/site-packages/astropy/utils/tests/test_data_info.py ............ [ 95%] | |
pypy/site-packages/astropy/utils/tests/test_decorators.py .............. [ 95%] | |
........... [ 95%] | |
pypy/site-packages/astropy/utils/tests/test_diff.py .................. [ 95%] | |
pypy/site-packages/astropy/utils/tests/test_introspection.py ..... [ 95%] | |
pypy/site-packages/astropy/utils/tests/test_metadata.py ................ [ 95%] | |
... [ 95%] | |
pypy/site-packages/astropy/utils/tests/test_misc.py ..s...s... [ 95%] | |
pypy/site-packages/astropy/utils/tests/test_timer.py . [ 95%] | |
pypy/site-packages/astropy/utils/tests/test_xml.py .........s [ 95%] | |
pypy/site-packages/astropy/utils/xml/tests/test_iterparse.py . [ 95%] | |
pypy/site-packages/astropy/visualization/scripts/tests/test_fits2bitmap.py s [ 95%] | |
ssssss [ 95%] | |
pypy/site-packages/astropy/visualization/tests/test_histogram.py sss. [ 95%] | |
pypy/site-packages/astropy/visualization/tests/test_interval.py ........ [ 95%] | |
................... [ 96%] | |
pypy/site-packages/astropy/visualization/tests/test_lupton_rgb.py ...... [ 96%] | |
...ss..s. [ 96%] | |
pypy/site-packages/astropy/visualization/tests/test_norm.py .sssssssssss [ 96%] | |
ssssssssss [ 96%] | |
pypy/site-packages/astropy/visualization/tests/test_stretch.py ......... [ 96%] | |
........................................................................ [ 96%] | |
.......................... [ 97%] | |
pypy/site-packages/astropy/visualization/tests/test_units.py sssss [ 97%] | |
pypy/site-packages/astropy/wcs/tests/test_pickle.py ...... [ 97%] | |
pypy/site-packages/astropy/wcs/tests/test_profiling.py ................. [ 97%] | |
................... [ 97%] | |
pypy/site-packages/astropy/wcs/tests/test_utils.py ....F................ [ 97%] | |
.......................................sss [ 97%] | |
pypy/site-packages/astropy/wcs/tests/test_wcs.py ....................... [ 98%] | |
F......F.......................F........ [ 98%] | |
pypy/site-packages/astropy/wcs/tests/test_wcsprm.py .................... [ 98%] | |
........................................................................ [ 99%] | |
........x.....F............................... [ 99%] | |
pypy/site-packages/astropy/wcs/tests/extension/test_extension.py . [ 99%] | |
pypy/site-packages/astropy/wcs/wcsapi/tests/test_fitswcs.py ............ [ 99%] | |
....sssssss............. [ 99%] | |
pypy/site-packages/astropy/wcs/wcsapi/tests/test_high_level_api.py ... [ 99%] | |
pypy/site-packages/astropy/wcs/wcsapi/tests/test_high_level_wcs_wrapper.py . [ 99%] | |
. [ 99%] | |
pypy/site-packages/astropy/wcs/wcsapi/tests/test_low_level_api.py . [ 99%] | |
pypy/site-packages/astropy/wcs/wcsapi/tests/test_sliced_low_level_wcs.py . [ 99%] | |
.................................... [ 99%] | |
pypy/site-packages/astropy/wcs/wcsapi/tests/test_utils.py .... [100%] | |
=================================== FAILURES =================================== | |
____________________ TestChecksumFunctions.test_sample_file ____________________ | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x000000000ff9dfa0> | |
def test_sample_file(self): | |
hdul = fits.open(self.data('checksum.fits'), checksum=True) | |
> hdul.close() | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:41: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ TestChecksumFunctions.test_image_create ____________________ | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x000000000e1ce988> | |
def test_image_create(self): | |
n = np.arange(100, dtype=np.int64) | |
hdu = fits.PrimaryHDU(n) | |
hdu.writeto(self.temp('tmp.fits'), overwrite=True, checksum=True) | |
with fits.open(self.temp('tmp.fits'), checksum=True) as hdul: | |
assert (hdu.data == hdul[0].data).all() | |
assert 'CHECKSUM' in hdul[0].header | |
assert 'DATASUM' in hdul[0].header | |
if not sys.platform.startswith('win32'): | |
# The checksum ends up being different on Windows, possibly due | |
# to slight floating point differences | |
assert hdul[0].header['CHECKSUM'] == 'ZHMkeGKjZGKjbGKj' | |
> assert hdul[0].header['DATASUM'] == '4950' | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:56: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________________ TestChecksumFunctions.test_scaled_data ____________________ | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x000000001d1cd408> | |
def test_scaled_data(self): | |
with fits.open(self.data('scale.fits')) as hdul: | |
orig_data = hdul[0].data.copy() | |
hdul[0].scale('int16', 'old') | |
hdul.writeto(self.temp('tmp.fits'), overwrite=True, checksum=True) | |
with fits.open(self.temp('tmp.fits'), checksum=True) as hdul1: | |
assert (hdul1[0].data == orig_data).all() | |
assert 'CHECKSUM' in hdul1[0].header | |
assert hdul1[0].header['CHECKSUM'] == 'cUmaeUjZcUjacUjW' | |
assert 'DATASUM' in hdul1[0].header | |
> assert hdul1[0].header['DATASUM'] == '1891563534' | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:68: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000001d1cde88>] | |
type = None, value = None, traceback = None | |
def __exit__(self, type, value, traceback): | |
> self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000001d1cde88>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
self.flush(output_verify=output_verify, verbose=verbose) | |
finally: | |
if self._file and closed and hasattr(self._file, 'close'): | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x000000001d1cd408> | |
def test_scaled_data(self): | |
with fits.open(self.data('scale.fits')) as hdul: | |
orig_data = hdul[0].data.copy() | |
hdul[0].scale('int16', 'old') | |
hdul.writeto(self.temp('tmp.fits'), overwrite=True, checksum=True) | |
with fits.open(self.temp('tmp.fits'), checksum=True) as hdul1: | |
assert (hdul1[0].data == orig_data).all() | |
assert 'CHECKSUM' in hdul1[0].header | |
assert hdul1[0].header['CHECKSUM'] == 'cUmaeUjZcUjacUjW' | |
assert 'DATASUM' in hdul1[0].header | |
> assert hdul1[0].header['DATASUM'] == '1891563534' | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:68: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________ TestChecksumFunctions.test_scaled_data_auto_rescale ______________ | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x0000000011571e50> | |
def test_scaled_data_auto_rescale(self): | |
""" | |
Regression test for | |
https://github.com/astropy/astropy/issues/3883#issuecomment-115122647 | |
Ensure that when scaled data is automatically rescaled on | |
opening/writing a file that the checksum and datasum are computed for | |
the rescaled array. | |
""" | |
with fits.open(self.data('scale.fits')) as hdul: | |
# Write out a copy of the data with the rescaling applied | |
> hdul.writeto(self.temp('rescaled.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:82: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________________ TestChecksumFunctions.test_uint16_data ____________________ | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x00000000150a0528> | |
def test_uint16_data(self): | |
checksums = [ | |
('aDcXaCcXaCcXaCcX', '0'), ('oYiGqXi9oXiEoXi9', '1746888714'), | |
('VhqQWZoQVfoQVZoQ', '0'), ('4cPp5aOn4aOn4aOn', '0'), | |
('8aCN8X9N8aAN8W9N', '1756785133'), ('UhqdUZnbUfnbUZnb', '0'), | |
('4cQJ5aN94aNG4aN9', '0')] | |
with fits.open(self.data('o4sp040b0_raw.fits'), uint=True) as hdul: | |
hdul.writeto(self.temp('tmp.fits'), overwrite=True, checksum=True) | |
with fits.open(self.temp('tmp.fits'), uint=True, | |
checksum=True) as hdul1: | |
for idx, (hdu_a, hdu_b) in enumerate(zip(hdul, hdul1)): | |
if hdu_a.data is None or hdu_b.data is None: | |
assert hdu_a.data is hdu_b.data | |
else: | |
assert (hdu_a.data == hdu_b.data).all() | |
assert 'CHECKSUM' in hdul[idx].header | |
assert hdul[idx].header['CHECKSUM'] == checksums[idx][0] | |
assert 'DATASUM' in hdul[idx].header | |
> assert hdul[idx].header['DATASUM'] == checksums[idx][1] | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:130: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000000e4e8170>, <astropy.io.fits.hdu.image.ImageHDU object at 0x...ts.hdu.image.ImageHDU object at 0x0000000013ac2c28>, <astropy.io.fits.hdu.image.ImageHDU object at 0x0000000014e667c8>] | |
type = None, value = None, traceback = None | |
def __exit__(self, type, value, traceback): | |
> self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000000e4e8170>, <astropy.io.fits.hdu.image.ImageHDU object at 0x...ts.hdu.image.ImageHDU object at 0x0000000013ac2c28>, <astropy.io.fits.hdu.image.ImageHDU object at 0x0000000014e667c8>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
self.flush(output_verify=output_verify, verbose=verbose) | |
finally: | |
if self._file and closed and hasattr(self._file, 'close'): | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x00000000150a0528> | |
def test_uint16_data(self): | |
checksums = [ | |
('aDcXaCcXaCcXaCcX', '0'), ('oYiGqXi9oXiEoXi9', '1746888714'), | |
('VhqQWZoQVfoQVZoQ', '0'), ('4cPp5aOn4aOn4aOn', '0'), | |
('8aCN8X9N8aAN8W9N', '1756785133'), ('UhqdUZnbUfnbUZnb', '0'), | |
('4cQJ5aN94aNG4aN9', '0')] | |
with fits.open(self.data('o4sp040b0_raw.fits'), uint=True) as hdul: | |
hdul.writeto(self.temp('tmp.fits'), overwrite=True, checksum=True) | |
with fits.open(self.temp('tmp.fits'), uint=True, | |
checksum=True) as hdul1: | |
for idx, (hdu_a, hdu_b) in enumerate(zip(hdul, hdul1)): | |
if hdu_a.data is None or hdu_b.data is None: | |
assert hdu_a.data is hdu_b.data | |
else: | |
assert (hdu_a.data == hdu_b.data).all() | |
assert 'CHECKSUM' in hdul[idx].header | |
assert hdul[idx].header['CHECKSUM'] == checksums[idx][0] | |
assert 'DATASUM' in hdul[idx].header | |
> assert hdul[idx].header['DATASUM'] == checksums[idx][1] | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:130: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________________ TestChecksumFunctions.test_groups_hdu_data __________________ | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x000000000f115830> | |
def test_groups_hdu_data(self): | |
imdata = np.arange(100.0) | |
imdata.shape = (10, 1, 1, 2, 5) | |
pdata1 = np.arange(10) + 0.1 | |
pdata2 = 42 | |
x = fits.hdu.groups.GroupData(imdata, parnames=['abc', 'xyz'], | |
pardata=[pdata1, pdata2], bitpix=-32) | |
hdu = fits.GroupsHDU(x) | |
hdu.writeto(self.temp('tmp.fits'), overwrite=True, checksum=True) | |
with fits.open(self.temp('tmp.fits'), checksum=True) as hdul: | |
assert comparerecords(hdul[0].data, hdu.data) | |
assert 'CHECKSUM' in hdul[0].header | |
assert hdul[0].header['CHECKSUM'] == '3eDQAZDO4dDOAZDO' | |
assert 'DATASUM' in hdul[0].header | |
> assert hdul[0].header['DATASUM'] == '2797758084' | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:146: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________ TestChecksumFunctions.test_binary_table_data _________________ | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x000000000d29df30> | |
def test_binary_table_data(self): | |
a1 = np.array(['NGC1001', 'NGC1002', 'NGC1003']) | |
a2 = np.array([11.1, 12.3, 15.2]) | |
col1 = fits.Column(name='target', format='20A', array=a1) | |
col2 = fits.Column(name='V_mag', format='E', array=a2) | |
cols = fits.ColDefs([col1, col2]) | |
tbhdu = fits.BinTableHDU.from_columns(cols) | |
tbhdu.writeto(self.temp('tmp.fits'), overwrite=True, checksum=True) | |
with fits.open(self.temp('tmp.fits'), checksum=True) as hdul: | |
assert comparerecords(tbhdu.data, hdul[1].data) | |
assert 'CHECKSUM' in hdul[0].header | |
assert hdul[0].header['CHECKSUM'] == 'D8iBD6ZAD6fAD6ZA' | |
assert 'DATASUM' in hdul[0].header | |
assert hdul[0].header['DATASUM'] == '0' | |
assert 'CHECKSUM' in hdul[1].header | |
assert hdul[1].header['CHECKSUM'] == 'aD1Oa90MaC0Ma90M' | |
assert 'DATASUM' in hdul[1].header | |
> assert hdul[1].header['DATASUM'] == '1062205743' | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:165: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________ TestChecksumFunctions.test_variable_length_table_data _____________ | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x0000000016b18e20> | |
def test_variable_length_table_data(self): | |
c1 = fits.Column(name='var', format='PJ()', | |
array=np.array([[45.0, 56], np.array([11, 12, 13])], | |
'O')) | |
c2 = fits.Column(name='xyz', format='2I', array=[[11, 3], [12, 4]]) | |
tbhdu = fits.BinTableHDU.from_columns([c1, c2]) | |
tbhdu.writeto(self.temp('tmp.fits'), overwrite=True, checksum=True) | |
with fits.open(self.temp('tmp.fits'), checksum=True) as hdul: | |
assert comparerecords(tbhdu.data, hdul[1].data) | |
assert 'CHECKSUM' in hdul[0].header | |
assert hdul[0].header['CHECKSUM'] == 'D8iBD6ZAD6fAD6ZA' | |
assert 'DATASUM' in hdul[0].header | |
assert hdul[0].header['DATASUM'] == '0' | |
assert 'CHECKSUM' in hdul[1].header | |
assert hdul[1].header['CHECKSUM'] == 'YIGoaIEmZIEmaIEm' | |
assert 'DATASUM' in hdul[1].header | |
> assert hdul[1].header['DATASUM'] == '1507485' | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:183: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________ TestChecksumFunctions.test_ascii_table_data __________________ | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x000000001107fad0> | |
def test_ascii_table_data(self): | |
a1 = np.array(['abc', 'def']) | |
r1 = np.array([11.0, 12.0]) | |
c1 = fits.Column(name='abc', format='A3', array=a1) | |
# This column used to be E format, but the single-precision float lost | |
# too much precision when scaling so it was changed to a D | |
c2 = fits.Column(name='def', format='D', array=r1, bscale=2.3, | |
bzero=0.6) | |
c3 = fits.Column(name='t1', format='I', array=[91, 92, 93]) | |
x = fits.ColDefs([c1, c2, c3]) | |
hdu = fits.TableHDU.from_columns(x) | |
hdu.writeto(self.temp('tmp.fits'), overwrite=True, checksum=True) | |
with fits.open(self.temp('tmp.fits'), checksum=True) as hdul: | |
assert comparerecords(hdu.data, hdul[1].data) | |
assert 'CHECKSUM' in hdul[0].header | |
assert hdul[0].header['CHECKSUM'] == 'D8iBD6ZAD6fAD6ZA' | |
assert 'DATASUM' in hdul[0].header | |
assert hdul[0].header['DATASUM'] == '0' | |
if not sys.platform.startswith('win32'): | |
# The checksum ends up being different on Windows, possibly due | |
# to slight floating point differences | |
assert 'CHECKSUM' in hdul[1].header | |
assert hdul[1].header['CHECKSUM'] == '3rKFAoI94oICAoI9' | |
assert 'DATASUM' in hdul[1].header | |
> assert hdul[1].header['DATASUM'] == '1914653725' | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:210: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________ TestChecksumFunctions.test_compressed_image_data _______________ | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x000000000d32cb48> | |
def test_compressed_image_data(self): | |
with fits.open(self.data('comp.fits')) as h1: | |
h1.writeto(self.temp('tmp.fits'), overwrite=True, checksum=True) | |
with fits.open(self.temp('tmp.fits'), checksum=True) as h2: | |
assert np.all(h1[1].data == h2[1].data) | |
assert 'CHECKSUM' in h2[0].header | |
assert h2[0].header['CHECKSUM'] == 'D8iBD6ZAD6fAD6ZA' | |
assert 'DATASUM' in h2[0].header | |
assert h2[0].header['DATASUM'] == '0' | |
assert 'CHECKSUM' in h2[1].header | |
assert h2[1].header['CHECKSUM'] == 'ZeAbdb8aZbAabb7a' | |
assert 'DATASUM' in h2[1].header | |
> assert h2[1].header['DATASUM'] == '113055149' | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:224: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000001692e090>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x0000000017f452f0>] | |
type = None, value = None, traceback = None | |
def __exit__(self, type, value, traceback): | |
> self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000001692e090>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x0000000017f452f0>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
self.flush(output_verify=output_verify, verbose=verbose) | |
finally: | |
if self._file and closed and hasattr(self._file, 'close'): | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x000000000d32cb48> | |
def test_compressed_image_data(self): | |
with fits.open(self.data('comp.fits')) as h1: | |
h1.writeto(self.temp('tmp.fits'), overwrite=True, checksum=True) | |
with fits.open(self.temp('tmp.fits'), checksum=True) as h2: | |
assert np.all(h1[1].data == h2[1].data) | |
assert 'CHECKSUM' in h2[0].header | |
assert h2[0].header['CHECKSUM'] == 'D8iBD6ZAD6fAD6ZA' | |
assert 'DATASUM' in h2[0].header | |
assert h2[0].header['DATASUM'] == '0' | |
assert 'CHECKSUM' in h2[1].header | |
assert h2[1].header['CHECKSUM'] == 'ZeAbdb8aZbAabb7a' | |
assert 'DATASUM' in h2[1].header | |
> assert h2[1].header['DATASUM'] == '113055149' | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:224: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________ TestChecksumFunctions.test_compressed_image_data_int16 ____________ | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x000000000c664608> | |
def test_compressed_image_data_int16(self): | |
n = np.arange(100, dtype='int16') | |
hdu = fits.ImageHDU(n) | |
comp_hdu = fits.CompImageHDU(hdu.data, hdu.header) | |
comp_hdu.writeto(self.temp('tmp.fits'), checksum=True) | |
hdu.writeto(self.temp('uncomp.fits'), checksum=True) | |
with fits.open(self.temp('tmp.fits'), checksum=True) as hdul: | |
assert np.all(hdul[1].data == comp_hdu.data) | |
assert np.all(hdul[1].data == hdu.data) | |
assert 'CHECKSUM' in hdul[0].header | |
assert hdul[0].header['CHECKSUM'] == 'D8iBD6ZAD6fAD6ZA' | |
assert 'DATASUM' in hdul[0].header | |
assert hdul[0].header['DATASUM'] == '0' | |
assert 'CHECKSUM' in hdul[1].header | |
assert hdul[1]._header['CHECKSUM'] == 'J5cCJ5c9J5cAJ5c9' | |
assert 'DATASUM' in hdul[1].header | |
assert hdul[1]._header['DATASUM'] == '2453673070' | |
assert 'CHECKSUM' in hdul[1].header | |
with fits.open(self.temp('uncomp.fits'), checksum=True) as hdul2: | |
header_comp = hdul[1]._header | |
header_uncomp = hdul2[1].header | |
assert 'ZHECKSUM' in header_comp | |
assert 'CHECKSUM' in header_uncomp | |
assert header_uncomp['CHECKSUM'] == 'ZE94eE91ZE91bE91' | |
assert header_comp['ZHECKSUM'] == header_uncomp['CHECKSUM'] | |
assert 'ZDATASUM' in header_comp | |
assert 'DATASUM' in header_uncomp | |
assert header_uncomp['DATASUM'] == '160565700' | |
> assert header_comp['ZDATASUM'] == header_uncomp['DATASUM'] | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:256: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000000ee83520>, <astropy.io.fits.hdu.image.ImageHDU object at 0x000000000e027750>] | |
type = None, value = None, traceback = None | |
def __exit__(self, type, value, traceback): | |
> self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000000ee83520>, <astropy.io.fits.hdu.image.ImageHDU object at 0x000000000e027750>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
self.flush(output_verify=output_verify, verbose=verbose) | |
finally: | |
if self._file and closed and hasattr(self._file, 'close'): | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x000000000c664608> | |
def test_compressed_image_data_int16(self): | |
n = np.arange(100, dtype='int16') | |
hdu = fits.ImageHDU(n) | |
comp_hdu = fits.CompImageHDU(hdu.data, hdu.header) | |
comp_hdu.writeto(self.temp('tmp.fits'), checksum=True) | |
hdu.writeto(self.temp('uncomp.fits'), checksum=True) | |
with fits.open(self.temp('tmp.fits'), checksum=True) as hdul: | |
assert np.all(hdul[1].data == comp_hdu.data) | |
assert np.all(hdul[1].data == hdu.data) | |
assert 'CHECKSUM' in hdul[0].header | |
assert hdul[0].header['CHECKSUM'] == 'D8iBD6ZAD6fAD6ZA' | |
assert 'DATASUM' in hdul[0].header | |
assert hdul[0].header['DATASUM'] == '0' | |
assert 'CHECKSUM' in hdul[1].header | |
assert hdul[1]._header['CHECKSUM'] == 'J5cCJ5c9J5cAJ5c9' | |
assert 'DATASUM' in hdul[1].header | |
assert hdul[1]._header['DATASUM'] == '2453673070' | |
assert 'CHECKSUM' in hdul[1].header | |
with fits.open(self.temp('uncomp.fits'), checksum=True) as hdul2: | |
header_comp = hdul[1]._header | |
header_uncomp = hdul2[1].header | |
assert 'ZHECKSUM' in header_comp | |
assert 'CHECKSUM' in header_uncomp | |
assert header_uncomp['CHECKSUM'] == 'ZE94eE91ZE91bE91' | |
assert header_comp['ZHECKSUM'] == header_uncomp['CHECKSUM'] | |
assert 'ZDATASUM' in header_comp | |
assert 'DATASUM' in header_uncomp | |
assert header_uncomp['DATASUM'] == '160565700' | |
> assert header_comp['ZDATASUM'] == header_uncomp['DATASUM'] | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:256: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________ TestChecksumFunctions.test_compressed_image_data_float32 ___________ | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x000000000d2ea288> | |
def test_compressed_image_data_float32(self): | |
n = np.arange(100, dtype='float32') | |
hdu = fits.ImageHDU(n) | |
comp_hdu = fits.CompImageHDU(hdu.data, hdu.header) | |
comp_hdu.writeto(self.temp('tmp.fits'), checksum=True) | |
hdu.writeto(self.temp('uncomp.fits'), checksum=True) | |
with fits.open(self.temp('tmp.fits'), checksum=True) as hdul: | |
assert np.all(hdul[1].data == comp_hdu.data) | |
assert np.all(hdul[1].data == hdu.data) | |
assert 'CHECKSUM' in hdul[0].header | |
assert hdul[0].header['CHECKSUM'] == 'D8iBD6ZAD6fAD6ZA' | |
assert 'DATASUM' in hdul[0].header | |
assert hdul[0].header['DATASUM'] == '0' | |
assert 'CHECKSUM' in hdul[1].header | |
assert 'DATASUM' in hdul[1].header | |
if not sys.platform.startswith('win32'): | |
# The checksum ends up being different on Windows, possibly due | |
# to slight floating point differences | |
assert hdul[1]._header['CHECKSUM'] == 'eATIf3SHe9SHe9SH' | |
assert hdul[1]._header['DATASUM'] == '1277667818' | |
with fits.open(self.temp('uncomp.fits'), checksum=True) as hdul2: | |
header_comp = hdul[1]._header | |
header_uncomp = hdul2[1].header | |
assert 'ZHECKSUM' in header_comp | |
assert 'CHECKSUM' in header_uncomp | |
assert header_uncomp['CHECKSUM'] == 'Cgr5FZo2Cdo2CZo2' | |
assert header_comp['ZHECKSUM'] == header_uncomp['CHECKSUM'] | |
assert 'ZDATASUM' in header_comp | |
assert 'DATASUM' in header_uncomp | |
assert header_uncomp['DATASUM'] == '2393636889' | |
> assert header_comp['ZDATASUM'] == header_uncomp['DATASUM'] | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:291: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000000e10e448>, <astropy.io.fits.hdu.image.ImageHDU object at 0x000000000e10e6b0>] | |
type = None, value = None, traceback = None | |
def __exit__(self, type, value, traceback): | |
> self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000000e10e448>, <astropy.io.fits.hdu.image.ImageHDU object at 0x000000000e10e6b0>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
self.flush(output_verify=output_verify, verbose=verbose) | |
finally: | |
if self._file and closed and hasattr(self._file, 'close'): | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x000000000d2ea288> | |
def test_compressed_image_data_float32(self): | |
n = np.arange(100, dtype='float32') | |
hdu = fits.ImageHDU(n) | |
comp_hdu = fits.CompImageHDU(hdu.data, hdu.header) | |
comp_hdu.writeto(self.temp('tmp.fits'), checksum=True) | |
hdu.writeto(self.temp('uncomp.fits'), checksum=True) | |
with fits.open(self.temp('tmp.fits'), checksum=True) as hdul: | |
assert np.all(hdul[1].data == comp_hdu.data) | |
assert np.all(hdul[1].data == hdu.data) | |
assert 'CHECKSUM' in hdul[0].header | |
assert hdul[0].header['CHECKSUM'] == 'D8iBD6ZAD6fAD6ZA' | |
assert 'DATASUM' in hdul[0].header | |
assert hdul[0].header['DATASUM'] == '0' | |
assert 'CHECKSUM' in hdul[1].header | |
assert 'DATASUM' in hdul[1].header | |
if not sys.platform.startswith('win32'): | |
# The checksum ends up being different on Windows, possibly due | |
# to slight floating point differences | |
assert hdul[1]._header['CHECKSUM'] == 'eATIf3SHe9SHe9SH' | |
assert hdul[1]._header['DATASUM'] == '1277667818' | |
with fits.open(self.temp('uncomp.fits'), checksum=True) as hdul2: | |
header_comp = hdul[1]._header | |
header_uncomp = hdul2[1].header | |
assert 'ZHECKSUM' in header_comp | |
assert 'CHECKSUM' in header_uncomp | |
assert header_uncomp['CHECKSUM'] == 'Cgr5FZo2Cdo2CZo2' | |
assert header_comp['ZHECKSUM'] == header_uncomp['CHECKSUM'] | |
assert 'ZDATASUM' in header_comp | |
assert 'DATASUM' in header_uncomp | |
assert header_uncomp['DATASUM'] == '2393636889' | |
> assert header_comp['ZDATASUM'] == header_uncomp['DATASUM'] | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:291: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________________ TestChecksumFunctions.test_append _______________________ | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x000000000ef70a30> | |
def test_append(self): | |
hdul = fits.open(self.data('tb.fits')) | |
hdul.writeto(self.temp('tmp.fits'), overwrite=True) | |
n = np.arange(100) | |
fits.append(self.temp('tmp.fits'), n, checksum=True) | |
> hdul.close() | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:302: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________ TestChecksumFunctions.test_writeto_convenience ________________ | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x00000000041d75c8> | |
def test_writeto_convenience(self): | |
n = np.arange(100) | |
fits.writeto(self.temp('tmp.fits'), n, overwrite=True, checksum=True) | |
hdul = fits.open(self.temp('tmp.fits'), checksum=True) | |
self._check_checksums(hdul[0]) | |
> hdul.close() | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:312: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________ TestChecksumFunctions.test_hdu_writeto_existing ________________ | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x000000000c63a100> | |
def test_hdu_writeto_existing(self): | |
""" | |
Tests that when using writeto with checksum=True, a checksum and | |
datasum are added to HDUs that did not previously have one. | |
Regression test for https://github.com/spacetelescope/PyFITS/issues/8 | |
""" | |
with fits.open(self.data('tb.fits')) as hdul: | |
> hdul.writeto(self.temp('test.fits'), checksum=True) | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:331: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________ TestChecksumFunctions.test_open_update_mode_preserve_checksum _________ | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x000000000c4eef00> | |
def test_open_update_mode_preserve_checksum(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/148 where | |
checksums are being removed from headers when a file is opened in | |
update mode, even though no changes were made to the file. | |
""" | |
self.copy_file('checksum.fits') | |
with fits.open(self.temp('checksum.fits')) as hdul: | |
> data = hdul[1].data.copy() | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:365: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________ TestChecksumFunctions.test_open_update_mode_update_checksum __________ | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x000000002082a170> | |
def test_open_update_mode_update_checksum(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/148, part | |
2. This ensures that if a file contains a checksum, the checksum is | |
updated when changes are saved to the file, even if the file was opened | |
with the default of checksum=False. | |
An existing checksum and/or datasum are only stripped if the file is | |
opened with checksum='remove'. | |
""" | |
self.copy_file('checksum.fits') | |
with fits.open(self.temp('checksum.fits')) as hdul: | |
header = hdul[1].header.copy() | |
> data = hdul[1].data.copy() | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:389: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________ TestChecksumFunctions.test_overwrite_invalid _________________ | |
self = <astropy.io.fits.tests.test_checksum.TestChecksumFunctions object at 0x0000000013adfbe8> | |
def test_overwrite_invalid(self): | |
""" | |
Tests that invalid checksum or datasum are overwriten when the file is | |
saved. | |
""" | |
reffile = self.temp('ref.fits') | |
with fits.open(self.data('tb.fits')) as hdul: | |
> hdul.writeto(reffile, checksum=True) | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py:427: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________________ TestSingleTable.test_memmap __________________________ | |
self = <astropy.io.fits.tests.test_connect.TestSingleTable object at 0x000000000da78aa0> | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_memmap0') | |
def test_memmap(self, tmpdir): | |
filename = str(tmpdir.join('test_simple.fts')) | |
t1 = Table(self.data) | |
t1.write(filename, overwrite=True) | |
t2 = Table.read(filename, memmap=False) | |
> t3 = Table.read(filename, memmap=True) | |
pypy/site-packages/astropy/io/fits/tests/test_connect.py:241: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/table/connect.py:52: in __call__ | |
out = registry.read(cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/io/fits/connect.py:218: in read_table_fits | |
hdulist.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________ TestSingleTable.test_character_as_bytes[True] _________________ | |
self = <astropy.io.fits.tests.test_connect.TestSingleTable object at 0x000000001699c090> | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_character_as_bytes_True_0') | |
memmap = True | |
@pytest.mark.parametrize('memmap', (False, True)) | |
def test_character_as_bytes(self, tmpdir, memmap): | |
filename = str(tmpdir.join('test_simple.fts')) | |
t1 = Table(self.data) | |
t1.write(filename, overwrite=True) | |
> t2 = Table.read(filename, character_as_bytes=False, memmap=memmap) | |
pypy/site-packages/astropy/io/fits/tests/test_connect.py:253: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/table/connect.py:52: in __call__ | |
out = registry.read(cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/io/fits/connect.py:218: in read_table_fits | |
hdulist.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________________________ test_bool_column _______________________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_bool_column0') | |
def test_bool_column(tmpdir): | |
""" | |
Regression test for https://github.com/astropy/astropy/issues/1953 | |
Ensures that Table columns of bools are properly written to a FITS table. | |
""" | |
arr = np.ones(5, dtype=bool) | |
arr[::2] == np.False_ | |
t = Table([arr]) | |
t.write(str(tmpdir.join('test.fits')), overwrite=True) | |
with fits.open(str(tmpdir.join('test.fits'))) as hdul: | |
assert hdul[1].data['col0'].dtype == np.dtype('bool') | |
> assert np.all(hdul[1].data['col0'] == arr) | |
pypy/site-packages/astropy/io/fits/tests/test_connect.py:541: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________________________ test_unicode_column ______________________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_unicode_column0') | |
def test_unicode_column(tmpdir): | |
""" | |
Test that a column of unicode strings is still written as one | |
byte-per-character in the FITS table (so long as the column can be ASCII | |
encoded). | |
Regression test for one of the issues fixed in | |
https://github.com/astropy/astropy/pull/4228 | |
""" | |
t = Table([np.array(['a', 'b', 'cd'])]) | |
t.write(str(tmpdir.join('test.fits')), overwrite=True) | |
with fits.open(str(tmpdir.join('test.fits'))) as hdul: | |
assert np.all(hdul[1].data['col0'] == ['a', 'b', 'cd']) | |
> assert hdul[1].header['TFORM1'] == '2A' | |
pypy/site-packages/astropy/io/fits/tests/test_connect.py:559: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________________ TestConvenience.test_resource_warning _____________________ | |
self = <astropy.io.fits.tests.test_convenience.TestConvenience object at 0x000000000fbfcd78> | |
def test_resource_warning(self): | |
warnings.simplefilter('always', ResourceWarning) | |
with catch_warnings() as w: | |
> _ = fits.getdata(self.data('test0.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_convenience.py:26: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/convenience.py:204: in getdata | |
hdulist.close(closed=closed) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________ TestConvenience.test_image_extension_update_header ______________ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000002061a4f0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x000000002061a528>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
> self.flush(output_verify=output_verify, verbose=verbose) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:963: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
args = ([<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000002061a4f0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x000000002061a528>],) | |
kwargs = {'output_verify': 'exception', 'verbose': False} | |
curr_thread = <_MainThread(MainThread, started 140018066300352)> | |
single_thread = True | |
SigintHandler = <class 'astropy.io.fits.util.ignore_sigint.<locals>.wrapped.<locals>.SigintHandler'> | |
sigint_handler = <astropy.io.fits.util.ignore_sigint.<locals>.wrapped.<locals>.SigintHandler object at 0x000000002061be88> | |
old_handler = <built-in function default_int_handler> | |
@wraps(func) | |
def wrapped(*args, **kwargs): | |
# Get the name of the current thread and determine if this is a single | |
# threaded application | |
curr_thread = threading.currentThread() | |
single_thread = (threading.activeCount() == 1 and | |
curr_thread.getName() == 'MainThread') | |
class SigintHandler: | |
def __init__(self): | |
self.sigint_received = False | |
def __call__(self, signum, frame): | |
warnings.warn('KeyboardInterrupt ignored until {} is ' | |
'complete!'.format(func.__name__), | |
AstropyUserWarning) | |
self.sigint_received = True | |
sigint_handler = SigintHandler() | |
# Define new signal interput handler | |
if single_thread: | |
# Install new handler | |
old_handler = signal.signal(signal.SIGINT, sigint_handler) | |
try: | |
> func(*args, **kwargs) | |
pypy/site-packages/astropy/io/fits/util.py:241: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000002061a4f0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x000000002061a528>] | |
output_verify = 'exception', verbose = False | |
@ignore_sigint | |
def flush(self, output_verify='fix', verbose=False): | |
""" | |
Force a write of the `HDUList` back to the file (for append and | |
update modes only). | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print verbose messages | |
""" | |
if self._file.mode not in ('append', 'update', 'ostream'): | |
warnings.warn("Flush for '{}' mode is not supported." | |
.format(self._file.mode), AstropyUserWarning) | |
return | |
if self._save_backup and self._file.mode in ('append', 'update'): | |
filename = self._file.name | |
if os.path.exists(filename): | |
# The the file doesn't actually exist anymore for some reason | |
# then there's no point in trying to make a backup | |
backup = filename + '.bak' | |
idx = 1 | |
while os.path.exists(backup): | |
backup = filename + '.bak.' + str(idx) | |
idx += 1 | |
warnings.warn('Saving a backup of {} to {}.'.format( | |
filename, backup), AstropyUserWarning) | |
try: | |
shutil.copy(filename, backup) | |
except OSError as exc: | |
raise OSError('Failed to save backup to destination {}: ' | |
'{}'.format(filename, exc)) | |
self.verify(option=output_verify) | |
if self._file.mode in ('append', 'ostream'): | |
for hdu in self: | |
if verbose: | |
try: | |
extver = str(hdu._header['extver']) | |
except KeyError: | |
extver = '' | |
# only append HDU's which are "new" | |
if hdu._new: | |
hdu._prewriteto(checksum=hdu._output_checksum) | |
with _free_space_check(self): | |
hdu._writeto(self._file) | |
if verbose: | |
print('append HDU', hdu.name, extver) | |
hdu._new = False | |
hdu._postwriteto() | |
elif self._file.mode == 'update': | |
> self._flush_update() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:842: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000002061a4f0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x000000002061a528>] | |
def _flush_update(self): | |
"""Implements flushing changes to a file in update mode.""" | |
for hdu in self: | |
# Need to all _prewriteto() for each HDU first to determine if | |
# resizing will be necessary | |
hdu._prewriteto(checksum=hdu._output_checksum, inplace=True) | |
try: | |
self._wasresized() | |
# if the HDUList is resized, need to write out the entire contents of | |
# the hdulist to the file. | |
if self._resize or self._file.compression: | |
> self._flush_resize() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:1258: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000002061a4f0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x000000002061a528>] | |
def _flush_resize(self): | |
""" | |
Implements flushing changes in update mode when parts of one or more HDU | |
need to be resized. | |
""" | |
old_name = self._file.name | |
old_memmap = self._file.memmap | |
name = _tmp_name(old_name) | |
if not self._file.file_like: | |
old_mode = os.stat(old_name).st_mode | |
# The underlying file is an actual file object. The HDUList is | |
# resized, so we need to write it to a tmp file, delete the | |
# original file, and rename the tmp file to the original file. | |
if self._file.compression == 'gzip': | |
new_file = gzip.GzipFile(name, mode='ab+') | |
elif self._file.compression == 'bzip2': | |
if not HAS_BZ2: | |
raise ModuleNotFoundError( | |
"This Python installation does not provide the bz2 module.") | |
new_file = bz2.BZ2File(name, mode='w') | |
else: | |
new_file = name | |
with self.fromfile(new_file, mode='append') as hdulist: | |
for hdu in self: | |
hdu._writeto(hdulist._file, inplace=True, copy=True) | |
if sys.platform.startswith('win'): | |
# Collect a list of open mmaps to the data; this well be | |
# used later. See below. | |
mmaps = [(idx, _get_array_mmap(hdu.data), hdu.data) | |
for idx, hdu in enumerate(self) if hdu._has_data] | |
hdulist._file.close() | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:1307: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_convenience.TestConvenience object at 0x000000002061b4b0> | |
def test_image_extension_update_header(self): | |
""" | |
Test that _makehdu correctly includes the header. For example in the | |
fits.update convenience function. | |
""" | |
filename = self.temp('twoextension.fits') | |
hdus = [fits.PrimaryHDU(np.zeros((10, 10))), | |
fits.ImageHDU(np.zeros((10, 10)))] | |
fits.HDUList(hdus).writeto(filename) | |
fits.update(filename, | |
np.zeros((10, 10)), | |
header=fits.Header([('WHAT', 100)]), | |
> ext=1) | |
pypy/site-packages/astropy/io/fits/tests/test_convenience.py:192: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/convenience.py:723: in update | |
hdulist.close(closed=closed) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________________ TestConvenience.test_printdiff ________________________ | |
self = <astropy.io.fits.tests.test_convenience.TestConvenience object at 0x0000000018cf09c0> | |
def test_printdiff(self): | |
""" | |
Test that FITSDiff can run the different inputs without crashing. | |
""" | |
# Testing different string input options | |
> assert printdiff(self.data('arange.fits'), | |
self.data('blank.fits')) is None | |
pypy/site-packages/astropy/io/fits/tests/test_convenience.py:202: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/convenience.py:871: in printdiff | |
print(FITSDiff(inputa, inputb, **kwargs).report()) | |
pypy/site-packages/astropy/io/fits/diff.py:318: in __init__ | |
a.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________________ TestConvenience.test_tabledump ________________________ | |
self = <astropy.io.fits.tests.test_convenience.TestConvenience object at 0x0000000018893d38> | |
def test_tabledump(self): | |
""" | |
Regression test for https://github.com/astropy/astropy/issues/6937 | |
""" | |
# copy fits file to the temp directory | |
self.copy_file('tb.fits') | |
# test without datafile | |
> fits.tabledump(self.temp('tb.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_convenience.py:237: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/utils/decorators.py:521: in wrapper | |
return function(*args, **kwargs) | |
pypy/site-packages/astropy/io/fits/convenience.py:937: in tabledump | |
f.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________________ TestConvenience.test_append_filename _____________________ | |
self = <astropy.io.fits.tests.test_convenience.TestConvenience object at 0x000000001ba47210> | |
def test_append_filename(self): | |
""" | |
Test fits.append with a filename argument. | |
""" | |
data = np.arange(6) | |
testfile = self.temp('test_append_1.fits') | |
# Test case 1: creation of file | |
fits.append(testfile, data=data, checksum=True) | |
# Test case 2: append to existing file, with verify=True | |
# Also test that additional keyword can be passed to fitsopen | |
fits.append(testfile, data=data * 2, checksum=True, ignore_blank=True) | |
# Test case 3: append to existing file, with verify=False | |
fits.append(testfile, data=data * 3, checksum=True, verify=False) | |
with fits.open(testfile, checksum=True) as hdu1: | |
np.testing.assert_array_equal(hdu1[0].data, data) | |
np.testing.assert_array_equal(hdu1[1].data, data * 2) | |
> np.testing.assert_array_equal(hdu1[2].data, data * 3) | |
pypy/site-packages/astropy/io/fits/tests/test_convenience.py:264: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ TestConvenience.test_append_with_header ____________________ | |
self = <astropy.io.fits.tests.test_convenience.TestConvenience object at 0x000000001126ae90> | |
def test_append_with_header(self): | |
""" | |
Test fits.append with a fits Header, which triggers detection of the | |
HDU class. Regression test for | |
https://github.com/astropy/astropy/issues/8660 | |
""" | |
testfile = self.temp('test_append_1.fits') | |
with fits.open(self.data('test0.fits')) as hdus: | |
for hdu in hdus: | |
> fits.append(testfile, hdu.data, hdu.header, checksum=True) | |
pypy/site-packages/astropy/io/fits/tests/test_convenience.py:284: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________________________ TestCore.test_byteswap ____________________________ | |
self = <astropy.io.fits.tests.test_core.TestCore object at 0x000000000c9e9ad0> | |
def test_byteswap(self): | |
p = fits.PrimaryHDU() | |
l = fits.HDUList() | |
n = np.zeros(3, dtype='i2') | |
n[0] = 1 | |
n[1] = 60000 | |
n[2] = 2 | |
c = fits.Column(name='foo', format='i2', bscale=1, bzero=32768, | |
array=n) | |
t = fits.BinTableHDU.from_columns([c]) | |
l.append(p) | |
l.append(t) | |
l.writeto(self.temp('test.fits'), overwrite=True) | |
with fits.open(self.temp('test.fits')) as p: | |
> assert p[1].data[1]['foo'] == 60000.0 | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:74: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________________ TestCore.test_fits_file_path_object ______________________ | |
self = <astropy.io.fits.tests.test_core.TestCore object at 0x00000000169591d8> | |
def test_fits_file_path_object(self): | |
""" | |
Testing when fits file is passed as pathlib.Path object #4412. | |
""" | |
fpath = pathlib.Path(get_pkg_data_filename('data/tdim.fits')) | |
with fits.open(fpath) as hdulist: | |
assert hdulist[0].filebytes() == 2880 | |
assert hdulist[1].filebytes() == 5760 | |
with fits.open(self.data('tdim.fits')) as hdulist2: | |
> assert FITSDiff(hdulist2, hdulist).identical is True | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:86: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x00000000169597f8>, <astropy.io.fits.hdu.table.BinTableHDU object at 0x0000000016958cd0>] | |
type = None, value = None, traceback = None | |
def __exit__(self, type, value, traceback): | |
> self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x00000000169597f8>, <astropy.io.fits.hdu.table.BinTableHDU object at 0x0000000016958cd0>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
self.flush(output_verify=output_verify, verbose=verbose) | |
finally: | |
if self._file and closed and hasattr(self._file, 'close'): | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_core.TestCore object at 0x00000000169591d8> | |
def test_fits_file_path_object(self): | |
""" | |
Testing when fits file is passed as pathlib.Path object #4412. | |
""" | |
fpath = pathlib.Path(get_pkg_data_filename('data/tdim.fits')) | |
with fits.open(fpath) as hdulist: | |
assert hdulist[0].filebytes() == 2880 | |
assert hdulist[1].filebytes() == 5760 | |
with fits.open(self.data('tdim.fits')) as hdulist2: | |
> assert FITSDiff(hdulist2, hdulist).identical is True | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:86: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________________ TestCore.test_add_del_columns2 ________________________ | |
self = <astropy.io.fits.tests.test_core.TestCore object at 0x000000000dd6d0f8> | |
def test_add_del_columns2(self): | |
hdulist = fits.open(self.data('tb.fits')) | |
table = hdulist[1] | |
assert table.data.dtype.names == ('c1', 'c2', 'c3', 'c4') | |
assert table.columns.names == ['c1', 'c2', 'c3', 'c4'] | |
> table.columns.del_col('c1') | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:101: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/column.py:1743: in del_col | |
self._notify('column_removed', self, indx) | |
pypy/site-packages/astropy/io/fits/util.py:137: in _notify | |
method(*args, **kwargs) | |
pypy/site-packages/astropy/io/fits/hdu/table.py:589: in _update_column_removed | |
super()._update_column_removed(columns, idx) | |
pypy/site-packages/astropy/io/fits/hdu/table.py:233: in _update_column_removed | |
del self.data | |
pypy/site-packages/astropy/utils/decorators.py:765: in __delete__ | |
self.fdel(obj) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.hdu.table.BinTableHDU object at 0x000000000dd6c090> | |
def data(self): | |
# The deleter | |
if self._file is not None and self._data_loaded: | |
> data_refcount = sys.getrefcount(self.data) | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/hdu/base.py:117: AttributeError | |
______________________________ TestCore.test_uint ______________________________ | |
self = <astropy.io.fits.tests.test_core.TestCore object at 0x00000000152f48e0> | |
def test_uint(self): | |
filename = self.data('o4sp040b0_raw.fits') | |
with fits.open(filename, uint=False) as hdulist_f: | |
with fits.open(filename, uint=True) as hdulist_i: | |
assert hdulist_f[1].data.dtype == np.float32 | |
assert hdulist_i[1].data.dtype == np.uint16 | |
> assert np.all(hdulist_f[1].data == hdulist_i[1].data) | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:164: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000001533c3a0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x000000001533c3d8>] | |
type = None, value = None, traceback = None | |
def __exit__(self, type, value, traceback): | |
> self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000001533c3a0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x000000001533c3d8>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
self.flush(output_verify=output_verify, verbose=verbose) | |
finally: | |
if self._file and closed and hasattr(self._file, 'close'): | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_core.TestCore object at 0x00000000152f48e0> | |
def test_uint(self): | |
filename = self.data('o4sp040b0_raw.fits') | |
with fits.open(filename, uint=False) as hdulist_f: | |
with fits.open(filename, uint=True) as hdulist_i: | |
assert hdulist_f[1].data.dtype == np.float32 | |
assert hdulist_i[1].data.dtype == np.uint16 | |
> assert np.all(hdulist_f[1].data == hdulist_i[1].data) | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:164: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________________ TestCore.test_hdu_fromstring _________________________ | |
self = <astropy.io.fits.tests.test_core.TestCore object at 0x00000000161efc20> | |
def test_hdu_fromstring(self): | |
""" | |
Tests creating a fully-formed HDU object from a string containing the | |
bytes of the HDU. | |
""" | |
infile = self.data('test0.fits') | |
outfile = self.temp('test.fits') | |
with open(infile, 'rb') as fin: | |
dat = fin.read() | |
offset = 0 | |
with fits.open(infile) as hdul: | |
hdulen = hdul[0]._data_offset + hdul[0]._data_size | |
hdu = fits.PrimaryHDU.fromstring(dat[:hdulen]) | |
assert isinstance(hdu, fits.PrimaryHDU) | |
assert hdul[0].header == hdu.header | |
assert hdu.data is None | |
hdu.header['TEST'] = 'TEST' | |
hdu.writeto(outfile) | |
with fits.open(outfile) as hdul: | |
assert isinstance(hdu, fits.PrimaryHDU) | |
assert hdul[0].header[:-1] == hdu.header[:-1] | |
assert hdul[0].header['TEST'] == 'TEST' | |
assert hdu.data is None | |
with fits.open(infile)as hdul: | |
for ext_hdu in hdul[1:]: | |
offset += hdulen | |
hdulen = len(str(ext_hdu.header)) + ext_hdu._data_size | |
hdu = fits.ImageHDU.fromstring(dat[offset:offset + hdulen]) | |
assert isinstance(hdu, fits.ImageHDU) | |
assert ext_hdu.header == hdu.header | |
> assert (ext_hdu.data == hdu.data).all() | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:431: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________________ TestCore.test_nonstandard_hdu _________________________ | |
self = <astropy.io.fits.tests.test_core.TestCore object at 0x00000000185c5210> | |
def test_nonstandard_hdu(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/157 | |
Tests that "Nonstandard" HDUs with SIMPLE = F are read and written | |
without prepending a superfluous and unwanted standard primary HDU. | |
""" | |
data = np.arange(100, dtype=np.uint8) | |
hdu = fits.PrimaryHDU(data=data) | |
hdu.header['SIMPLE'] = False | |
hdu.writeto(self.temp('test.fits')) | |
info = [(0, '', 1, 'NonstandardHDU', 5, (), '', '')] | |
with fits.open(self.temp('test.fits')) as hdul: | |
assert hdul.info(output=False) == info | |
# NonstandardHDUs just treat the data as an unspecified array of | |
# bytes. The first 100 bytes should match the original data we | |
# passed in...the rest should be zeros padding out the rest of the | |
# FITS block | |
assert (hdul[0].data[:100] == data).all() | |
> assert (hdul[0].data[100:] == 0).all() | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:454: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________________ TestCore.test_consecutive_writeto _______________________ | |
self = <astropy.io.fits.tests.test_core.TestCore object at 0x0000000004e7a9c0> | |
def test_consecutive_writeto(self): | |
""" | |
Regression test for an issue where calling writeto twice on the same | |
HDUList could write a corrupted file. | |
https://github.com/spacetelescope/PyFITS/issues/40 is actually a | |
particular instance of this problem, though isn't unique to sys.stdout. | |
""" | |
with fits.open(self.data('test0.fits')) as hdul1: | |
# Add a bunch of header keywords so that the data will be forced to | |
# new offsets within the file: | |
for idx in range(40): | |
hdul1[1].header[f'TEST{idx}'] = 'test' | |
hdul1.writeto(self.temp('test1.fits')) | |
hdul1.writeto(self.temp('test2.fits')) | |
# Open a second handle to the original file and compare it to hdul1 | |
# (We only compare part of the one header that was modified) | |
# Compare also with the second writeto output | |
with fits.open(self.data('test0.fits')) as hdul2: | |
with fits.open(self.temp('test2.fits')) as hdul3: | |
for hdul in (hdul1, hdul3): | |
for idx, hdus in enumerate(zip(hdul2, hdul)): | |
hdu2, hdu = hdus | |
if idx != 1: | |
assert hdu.header == hdu2.header | |
else: | |
assert (hdu2.header == | |
hdu.header[:len(hdu2.header)]) | |
> assert np.all(hdu.data == hdu2.data) | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:551: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x00000000064b07c8>, <astropy.io.fits.hdu.image.ImageHDU object at 0x...ts.hdu.image.ImageHDU object at 0x000000001f919a60>, <astropy.io.fits.hdu.image.ImageHDU object at 0x000000001f85be18>] | |
type = None, value = None, traceback = None | |
def __exit__(self, type, value, traceback): | |
> self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x00000000064b07c8>, <astropy.io.fits.hdu.image.ImageHDU object at 0x...ts.hdu.image.ImageHDU object at 0x000000001f919a60>, <astropy.io.fits.hdu.image.ImageHDU object at 0x000000001f85be18>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
self.flush(output_verify=output_verify, verbose=verbose) | |
finally: | |
if self._file and closed and hasattr(self._file, 'close'): | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_core.TestCore object at 0x0000000004e7a9c0> | |
def test_consecutive_writeto(self): | |
""" | |
Regression test for an issue where calling writeto twice on the same | |
HDUList could write a corrupted file. | |
https://github.com/spacetelescope/PyFITS/issues/40 is actually a | |
particular instance of this problem, though isn't unique to sys.stdout. | |
""" | |
with fits.open(self.data('test0.fits')) as hdul1: | |
# Add a bunch of header keywords so that the data will be forced to | |
# new offsets within the file: | |
for idx in range(40): | |
hdul1[1].header[f'TEST{idx}'] = 'test' | |
hdul1.writeto(self.temp('test1.fits')) | |
hdul1.writeto(self.temp('test2.fits')) | |
# Open a second handle to the original file and compare it to hdul1 | |
# (We only compare part of the one header that was modified) | |
# Compare also with the second writeto output | |
with fits.open(self.data('test0.fits')) as hdul2: | |
with fits.open(self.temp('test2.fits')) as hdul3: | |
for hdul in (hdul1, hdul3): | |
for idx, hdus in enumerate(zip(hdul2, hdul)): | |
hdu2, hdu = hdus | |
if idx != 1: | |
assert hdu.header == hdu2.header | |
else: | |
assert (hdu2.header == | |
hdu.header[:len(hdu2.header)]) | |
> assert np.all(hdu.data == hdu2.data) | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:551: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000001456c790>, <astropy.io.fits.hdu.image.ImageHDU object at 0x...ts.hdu.image.ImageHDU object at 0x000000000e414db0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x000000000e414de8>] | |
type = <class 'AttributeError'> | |
value = AttributeError("module 'sys' has no attribute 'getrefcount'",) | |
traceback = <traceback object at 0x0000000014c6a040> | |
def __exit__(self, type, value, traceback): | |
> self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000001456c790>, <astropy.io.fits.hdu.image.ImageHDU object at 0x...ts.hdu.image.ImageHDU object at 0x000000000e414db0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x000000000e414de8>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
self.flush(output_verify=output_verify, verbose=verbose) | |
finally: | |
if self._file and closed and hasattr(self._file, 'close'): | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_core.TestCore object at 0x0000000004e7a9c0> | |
def test_consecutive_writeto(self): | |
""" | |
Regression test for an issue where calling writeto twice on the same | |
HDUList could write a corrupted file. | |
https://github.com/spacetelescope/PyFITS/issues/40 is actually a | |
particular instance of this problem, though isn't unique to sys.stdout. | |
""" | |
with fits.open(self.data('test0.fits')) as hdul1: | |
# Add a bunch of header keywords so that the data will be forced to | |
# new offsets within the file: | |
for idx in range(40): | |
hdul1[1].header[f'TEST{idx}'] = 'test' | |
hdul1.writeto(self.temp('test1.fits')) | |
hdul1.writeto(self.temp('test2.fits')) | |
# Open a second handle to the original file and compare it to hdul1 | |
# (We only compare part of the one header that was modified) | |
# Compare also with the second writeto output | |
with fits.open(self.data('test0.fits')) as hdul2: | |
with fits.open(self.temp('test2.fits')) as hdul3: | |
for hdul in (hdul1, hdul3): | |
for idx, hdus in enumerate(zip(hdul2, hdul)): | |
hdu2, hdu = hdus | |
if idx != 1: | |
assert hdu.header == hdu2.header | |
else: | |
assert (hdu2.header == | |
hdu.header[:len(hdu2.header)]) | |
> assert np.all(hdu.data == hdu2.data) | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:551: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________________ TestConvenienceFunctions.test_writeto _____________________ | |
self = <astropy.io.fits.tests.test_core.TestConvenienceFunctions object at 0x000000000dd445d0> | |
def test_writeto(self): | |
""" | |
Simple test for writing a trivial header and some data to a file | |
with the `writeto()` convenience function. | |
""" | |
filename = self.temp('array.fits') | |
data = np.zeros((100, 100)) | |
header = fits.Header() | |
fits.writeto(filename, data, header=header, overwrite=True) | |
with fits.open(filename) as hdul: | |
assert len(hdul) == 1 | |
> assert (data == hdul[0].data).all() | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:566: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ TestConvenienceFunctions.test_writeto_2 ____________________ | |
self = <astropy.io.fits.tests.test_core.TestConvenienceFunctions object at 0x000000000b64a090> | |
def test_writeto_2(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/107 | |
Test of `writeto()` with a trivial header containing a single keyword. | |
""" | |
filename = self.temp('array.fits') | |
data = np.zeros((100, 100)) | |
header = fits.Header() | |
header.set('CRPIX1', 1.) | |
fits.writeto(filename, data, header=header, | |
overwrite=True, output_verify='silentfix') | |
with fits.open(filename) as hdul: | |
assert len(hdul) == 1 | |
assert (data == hdul[0].data).all() | |
assert 'CRPIX1' in hdul[0].header | |
> assert hdul[0].header['CRPIX1'] == 1.0 | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:584: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________ TestFileFunctions.test_updated_file_permissions ________________ | |
self = <astropy.io.fits.tests.test_core.TestFileFunctions object at 0x000000000cca3088> | |
def test_updated_file_permissions(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/79 | |
Tests that when a FITS file is modified in update mode, the file | |
permissions are preserved. | |
""" | |
filename = self.temp('test.fits') | |
hdul = [fits.PrimaryHDU(), fits.ImageHDU()] | |
hdul = fits.HDUList(hdul) | |
hdul.writeto(filename) | |
old_mode = os.stat(filename).st_mode | |
hdul = fits.open(filename, mode='update') | |
hdul.insert(1, fits.ImageHDU()) | |
> hdul.flush() | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:947: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/util.py:241: in wrapped | |
func(*args, **kwargs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:842: in flush | |
self._flush_update() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:1258: in _flush_update | |
self._flush_resize() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:1307: in _flush_resize | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ TestFileFunctions.test_mmap_unwriteable ____________________ | |
self = <astropy.io.fits.tests.test_core.TestFileFunctions object at 0x0000000016b18f70> | |
def test_mmap_unwriteable(self): | |
"""Regression test for https://github.com/astropy/astropy/issues/968 | |
Temporarily patches mmap.mmap to exhibit platform-specific bad | |
behavior. | |
""" | |
class MockMmap(mmap.mmap): | |
def flush(self): | |
raise OSError('flush is broken on this platform') | |
old_mmap = mmap.mmap | |
mmap.mmap = MockMmap | |
# Force the mmap test to be rerun | |
_File.__dict__['_mmap_available']._cache.clear() | |
try: | |
self.copy_file('test0.fits') | |
with catch_warnings() as w: | |
with fits.open(self.temp('test0.fits'), mode='update', | |
memmap=True) as h: | |
h[1].data[0, 0] = 999 | |
assert len(w) == 1 | |
assert 'mmap.flush is unavailable' in str(w[0].message) | |
# Double check that writing without mmap still worked | |
with fits.open(self.temp('test0.fits')) as h: | |
> assert h[1].data[0, 0] == 999 | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:1027: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________________ TestFileFunctions.test_mmap_allocate_error __________________ | |
self = <astropy.io.fits.tests.test_core.TestFileFunctions object at 0x000000001831dbb0> | |
@pytest.mark.openfiles_ignore | |
def test_mmap_allocate_error(self): | |
""" | |
Regression test for https://github.com/astropy/astropy/issues/1380 | |
Temporarily patches mmap.mmap to raise an OSError if mode is ACCESS_COPY. | |
""" | |
mmap_original = mmap.mmap | |
# We patch mmap here to raise an error if access=mmap.ACCESS_COPY, which | |
# emulates an issue that an OSError is raised if the available address | |
# space is less than the size of the file even if memory mapping is used. | |
def mmap_patched(*args, **kwargs): | |
if kwargs.get('access') == mmap.ACCESS_COPY: | |
exc = OSError() | |
exc.errno = errno.ENOMEM | |
raise exc | |
else: | |
return mmap_original(*args, **kwargs) | |
with fits.open(self.data('test0.fits'), memmap=True) as hdulist: | |
with patch.object(mmap, 'mmap', side_effect=mmap_patched) as p: | |
with pytest.warns(AstropyUserWarning, match=r"Could not memory " | |
r"map array with mode='readonly'"): | |
data = hdulist[1].data | |
p.reset_mock() | |
> assert not data.flags.writeable | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:1060: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________________ TestFileFunctions.test_mmap_closing ______________________ | |
self = <astropy.io.fits.tests.test_core.TestFileFunctions object at 0x0000000015357f30> | |
def test_mmap_closing(self): | |
""" | |
Tests that the mmap reference is closed/removed when there aren't any | |
HDU data references left. | |
""" | |
if not _File._mmap_available: | |
pytest.xfail('not expected to work on platforms without mmap ' | |
'support') | |
with fits.open(self.data('test0.fits'), memmap=True) as hdul: | |
assert hdul._file._mmap is None | |
hdul[1].data | |
assert hdul._file._mmap is not None | |
> del hdul[1].data | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:1078: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.utils.decorators.lazyproperty object at 0x00007f587adbe7a0> | |
obj = <astropy.io.fits.hdu.image.ImageHDU object at 0x0000000018b3d4b0> | |
def __delete__(self, obj): | |
if self.fdel: | |
> self.fdel(obj) | |
pypy/site-packages/astropy/utils/decorators.py:765: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.hdu.image.ImageHDU object at 0x0000000018b3d4b0> | |
def data(self): | |
# The deleter | |
if self._file is not None and self._data_loaded: | |
> data_refcount = sys.getrefcount(self.data) | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/hdu/base.py:117: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_core.TestFileFunctions object at 0x0000000015357f30> | |
def test_mmap_closing(self): | |
""" | |
Tests that the mmap reference is closed/removed when there aren't any | |
HDU data references left. | |
""" | |
if not _File._mmap_available: | |
pytest.xfail('not expected to work on platforms without mmap ' | |
'support') | |
with fits.open(self.data('test0.fits'), memmap=True) as hdul: | |
assert hdul._file._mmap is None | |
hdul[1].data | |
assert hdul._file._mmap is not None | |
del hdul[1].data | |
# Should be no more references to data in the file so close the | |
# mmap | |
assert hdul._file._mmap is None | |
hdul[1].data | |
hdul[2].data | |
del hdul[1].data | |
# hdul[2].data is still references so keep the mmap open | |
assert hdul._file._mmap is not None | |
del hdul[2].data | |
> assert hdul._file._mmap is None | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:1089: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ TestFileFunctions.test_uncloseable_file ____________________ | |
self = <astropy.io.fits.tests.test_core.TestFileFunctions object at 0x0000000017a7a8e0> | |
def test_uncloseable_file(self): | |
""" | |
Regression test for https://github.com/astropy/astropy/issues/2356 | |
Demonstrates that FITS files can still be read from "file-like" objects | |
that don't have an obvious "open" or "closed" state. | |
""" | |
class MyFileLike: | |
def __init__(self, foobar): | |
self._foobar = foobar | |
def read(self, n): | |
return self._foobar.read(n) | |
def seek(self, offset, whence=os.SEEK_SET): | |
self._foobar.seek(offset, whence) | |
def tell(self): | |
return self._foobar.tell() | |
with open(self.data('test0.fits'), 'rb') as f: | |
fileobj = MyFileLike(f) | |
with fits.open(fileobj) as hdul1: | |
with fits.open(self.data('test0.fits')) as hdul2: | |
assert hdul1.info(output=False) == hdul2.info(output=False) | |
for hdu1, hdu2 in zip(hdul1, hdul2): | |
assert hdu1.header == hdu2.header | |
if hdu1.data is not None and hdu2.data is not None: | |
> assert np.all(hdu1.data == hdu2.data) | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:1142: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________________ TestFileFunctions.test_write_bytesio _____________________ | |
self = <astropy.io.fits.tests.test_core.TestFileFunctions object at 0x00000000153a1910> | |
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()) | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:1170: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:1254: in _test_write_string_bytes_io | |
assert FITSDiff(hdul, hdul2).identical | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________________ TestFileFunctions.test_filename_with_colon __________________ | |
self = <astropy.io.fits.tests.test_core.TestFileFunctions object at 0x000000001484cfa8> | |
@pytest.mark.skipif('sys.platform.startswith("win32")') | |
def test_filename_with_colon(self): | |
""" | |
Test reading and writing a file with a colon in the filename. | |
Regression test for https://github.com/astropy/astropy/issues/3122 | |
""" | |
# Skip on Windows since colons in filenames makes NTFS sad. | |
filename = 'APEXHET.2014-04-01T15:18:01.000.fits' | |
hdu = fits.PrimaryHDU(data=np.arange(10)) | |
hdu.writeto(self.temp(filename)) | |
with fits.open(self.temp(filename)) as hdul: | |
> assert np.all(hdul[0].data == hdu.data) | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:1187: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________ TestStreamingFunctions.test_streaming_hdu_write_file _____________ | |
self = <astropy.io.fits.tests.test_core.TestStreamingFunctions object at 0x000000000f204c60> | |
def test_streaming_hdu_write_file(self): | |
"""Test streaming an HDU to an open file object.""" | |
arr = np.zeros((5, 5), dtype=np.int32) | |
with open(self.temp('new.fits'), 'ab+') as f: | |
shdu = self._make_streaming_hdu(f) | |
shdu.write(arr) | |
assert shdu.writecomplete | |
assert shdu.size == 100 | |
with fits.open(self.temp('new.fits')) as hdul: | |
assert len(hdul) == 1 | |
> assert (hdul[0].data == arr).all() | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:1313: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ TestStreamingFunctions.test_blank_ignore ___________________ | |
self = <astropy.io.fits.tests.test_core.TestStreamingFunctions object at 0x000000002213a5d0> | |
def test_blank_ignore(self): | |
with fits.open(self.data('blank.fits'), ignore_blank=True) as f: | |
> assert f[0].data.flat[0] == 2 | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:1372: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________ TestStreamingFunctions.test_error_if_memmap_impossible ____________ | |
self = <astropy.io.fits.tests.test_core.TestStreamingFunctions object at 0x0000000022906c60> | |
def test_error_if_memmap_impossible(self): | |
pth = self.data('blank.fits') | |
with fits.open(pth, memmap=True) as hdul: | |
with pytest.raises(ValueError): | |
> hdul[0].data | |
pypy/site-packages/astropy/io/fits/tests/test_core.py:1378: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ TestDiff.test_identical_comp_image_hdus ____________________ | |
self = <astropy.io.fits.tests.test_diff.TestDiff object at 0x000000001fdc8bb8> | |
def test_identical_comp_image_hdus(self): | |
"""Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/189 | |
For this test we mostly just care that comparing to compressed images | |
does not crash, and returns the correct results. Two compressed images | |
will be considered identical if the decompressed data is the same. | |
Obviously we test whether or not the same compression was used by | |
looking for (or ignoring) header differences. | |
""" | |
data = np.arange(100.0).reshape(10, 10) | |
hdu = fits.CompImageHDU(data=data) | |
hdu.writeto(self.temp('test.fits')) | |
with fits.open(self.temp('test.fits')) as hdula, \ | |
fits.open(self.temp('test.fits')) as hdulb: | |
diff = FITSDiff(hdula, hdulb) | |
> assert diff.identical | |
pypy/site-packages/astropy/io/fits/tests/test_diff.py:335: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000001feff558>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x000000001fefe758>] | |
type = None, value = None, traceback = None | |
def __exit__(self, type, value, traceback): | |
> self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000001feff558>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x000000001fefe758>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
self.flush(output_verify=output_verify, verbose=verbose) | |
finally: | |
if self._file and closed and hasattr(self._file, 'close'): | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_diff.TestDiff object at 0x000000001fdc8bb8> | |
def test_identical_comp_image_hdus(self): | |
"""Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/189 | |
For this test we mostly just care that comparing to compressed images | |
does not crash, and returns the correct results. Two compressed images | |
will be considered identical if the decompressed data is the same. | |
Obviously we test whether or not the same compression was used by | |
looking for (or ignoring) header differences. | |
""" | |
data = np.arange(100.0).reshape(10, 10) | |
hdu = fits.CompImageHDU(data=data) | |
hdu.writeto(self.temp('test.fits')) | |
with fits.open(self.temp('test.fits')) as hdula, \ | |
fits.open(self.temp('test.fits')) as hdulb: | |
diff = FITSDiff(hdula, hdulb) | |
> assert diff.identical | |
pypy/site-packages/astropy/io/fits/tests/test_diff.py:335: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________________ TestDiff.test_identical_files_basic ______________________ | |
self = <astropy.io.fits.tests.test_diff.TestDiff object at 0x000000000d5294e8> | |
def test_identical_files_basic(self): | |
"""Test identicality of two simple, extensionless files.""" | |
a = np.arange(100).reshape(10, 10) | |
hdu = PrimaryHDU(data=a) | |
hdu.writeto(self.temp('testa.fits')) | |
hdu.writeto(self.temp('testb.fits')) | |
> diff = FITSDiff(self.temp('testa.fits'), self.temp('testb.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_diff.py:586: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/diff.py:318: in __init__ | |
a.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________________ TestDivisionFunctions.test_rec_from_string __________________ | |
self = <astropy.io.fits.tests.test_division.TestDivisionFunctions object at 0x000000000a477520> | |
def test_rec_from_string(self): | |
with fits.open(self.data('tb.fits')) as t1: | |
> s = t1[1].data.tostring() | |
pypy/site-packages/astropy/io/fits/tests/test_division.py:15: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________________ TestFitscheck.test_valid_file _________________________ | |
self = <astropy.io.fits.tests.test_fitscheck.TestFitscheck object at 0x000000000cb4d948> | |
capsys = <_pytest.capture.CaptureFixture object at 0x000000000cb4c720> | |
def test_valid_file(self, capsys): | |
testfile = self.data('checksum.fits') | |
> assert fitscheck.main([testfile]) == 0 | |
E AssertionError: assert 1 == 0 | |
E + where 1 = <function main at 0x0000000008e0eb60>(['/home/tom/pypy/site-packages/astropy/io/fits/tests/data/checksum.fits']) | |
E + where <function main at 0x0000000008e0eb60> = fitscheck.main | |
pypy/site-packages/astropy/io/fits/tests/test_fitscheck.py:23: AssertionError | |
----------------------------- Captured stderr call ----------------------------- | |
--- Logging error --- | |
Traceback (most recent call last): | |
File "/home/tom/pypy/site-packages/astropy/io/fits/scripts/fitscheck.py", line 190, in process_file | |
checksum_errors = verify_checksums(filename) | |
File "/home/tom/pypy/site-packages/astropy/io/fits/scripts/fitscheck.py", line 145, in verify_checksums | |
return 1 | |
File "/home/tom/pypy/site-packages/astropy/io/fits/hdu/hdulist.py", line 381, in __exit__ | |
self.close() | |
File "/home/tom/pypy/site-packages/astropy/io/fits/hdu/hdulist.py", line 966, in close | |
self._file.close() | |
File "/home/tom/pypy/site-packages/astropy/io/fits/file.py", line 413, in close | |
self._maybe_close_mmap() | |
File "/home/tom/pypy/site-packages/astropy/io/fits/file.py", line 431, in _maybe_close_mmap | |
sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
AttributeError: module 'sys' has no attribute 'getrefcount' | |
During handling of the above exception, another exception occurred: | |
Traceback (most recent call last): | |
File "/home/tom/Downloads/pypy3.6-7.2.0-linux_x86_64-portable/lib-python/3/logging/__init__.py", line 996, in emit | |
stream.write(msg) | |
ValueError: I/O operation on closed file | |
Call stack: | |
File "<string>", line 1, in <module> | |
File "/home/tom/pypy/site-packages/astropy/tests/runner.py", line 266, in test | |
return runner.run_tests(**kwargs) | |
File "/home/tom/pypy/site-packages/astropy/tests/runner.py", line 611, in run_tests | |
return super().run_tests(**kwargs) | |
File "/home/tom/pypy/site-packages/astropy/tests/runner.py", line 248, in run_tests | |
return pytest.main(args=args, plugins=plugins) | |
File "/home/tom/pypy/site-packages/_pytest/config/__init__.py", line 92, in main | |
config=config | |
File "/home/tom/pypy/site-packages/pluggy/hooks.py", line 286, in __call__ | |
return self._hookexec(self, self.get_hookimpls(), kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 93, in _hookexec | |
return self._inner_hookexec(hook, methods, kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 87, in <lambda> | |
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, | |
File "/home/tom/pypy/site-packages/pluggy/callers.py", line 187, in _multicall | |
res = hook_impl.function(*args) | |
File "/home/tom/pypy/site-packages/_pytest/main.py", line 239, in pytest_cmdline_main | |
return wrap_session(config, _main) | |
File "/home/tom/pypy/site-packages/_pytest/main.py", line 196, in wrap_session | |
session.exitstatus = doit(config, session) or 0 | |
File "/home/tom/pypy/site-packages/_pytest/main.py", line 246, in _main | |
config.hook.pytest_runtestloop(session=session) | |
File "/home/tom/pypy/site-packages/pluggy/hooks.py", line 286, in __call__ | |
return self._hookexec(self, self.get_hookimpls(), kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 93, in _hookexec | |
return self._inner_hookexec(hook, methods, kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 87, in <lambda> | |
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, | |
File "/home/tom/pypy/site-packages/pluggy/callers.py", line 187, in _multicall | |
res = hook_impl.function(*args) | |
File "/home/tom/pypy/site-packages/_pytest/main.py", line 270, in pytest_runtestloop | |
item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem) | |
File "/home/tom/pypy/site-packages/pluggy/hooks.py", line 286, in __call__ | |
return self._hookexec(self, self.get_hookimpls(), kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 93, in _hookexec | |
return self._inner_hookexec(hook, methods, kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 87, in <lambda> | |
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, | |
File "/home/tom/pypy/site-packages/pluggy/callers.py", line 187, in _multicall | |
res = hook_impl.function(*args) | |
File "/home/tom/pypy/site-packages/_pytest/runner.py", line 81, in pytest_runtest_protocol | |
runtestprotocol(item, nextitem=nextitem) | |
File "/home/tom/pypy/site-packages/_pytest/runner.py", line 96, in runtestprotocol | |
reports.append(call_and_report(item, "call", log)) | |
File "/home/tom/pypy/site-packages/_pytest/runner.py", line 182, in call_and_report | |
call = call_runtest_hook(item, when, **kwds) | |
File "/home/tom/pypy/site-packages/_pytest/runner.py", line 207, in call_runtest_hook | |
lambda: ihook(item=item, **kwds), when=when, reraise=reraise | |
File "/home/tom/pypy/site-packages/_pytest/runner.py", line 234, in from_call | |
result = func() | |
File "/home/tom/pypy/site-packages/_pytest/runner.py", line 207, in <lambda> | |
lambda: ihook(item=item, **kwds), when=when, reraise=reraise | |
File "/home/tom/pypy/site-packages/pluggy/hooks.py", line 286, in __call__ | |
return self._hookexec(self, self.get_hookimpls(), kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 93, in _hookexec | |
return self._inner_hookexec(hook, methods, kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 87, in <lambda> | |
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, | |
File "/home/tom/pypy/site-packages/pluggy/callers.py", line 187, in _multicall | |
res = hook_impl.function(*args) | |
File "/home/tom/pypy/site-packages/_pytest/runner.py", line 131, in pytest_runtest_call | |
item.runtest() | |
File "/home/tom/pypy/site-packages/_pytest/python.py", line 1435, in runtest | |
self.ihook.pytest_pyfunc_call(pyfuncitem=self) | |
File "/home/tom/pypy/site-packages/pluggy/hooks.py", line 286, in __call__ | |
return self._hookexec(self, self.get_hookimpls(), kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 93, in _hookexec | |
return self._inner_hookexec(hook, methods, kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 87, in <lambda> | |
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, | |
File "/home/tom/pypy/site-packages/pluggy/callers.py", line 187, in _multicall | |
res = hook_impl.function(*args) | |
File "/home/tom/pypy/site-packages/_pytest/python.py", line 166, in pytest_pyfunc_call | |
result = testfunction(**testargs) | |
File "/home/tom/pypy/site-packages/astropy/io/fits/tests/test_fitscheck.py", line 23, in test_valid_file | |
assert fitscheck.main([testfile]) == 0 | |
File "/home/tom/pypy/site-packages/astropy/io/fits/scripts/fitscheck.py", line 213, in main | |
errors += process_file(filename) | |
File "/home/tom/pypy/site-packages/astropy/io/fits/scripts/fitscheck.py", line 199, in process_file | |
log.error(f'EXCEPTION {filename!r} .. {e}') | |
Message: "EXCEPTION '/home/tom/pypy/site-packages/astropy/io/fits/tests/data/checksum.fits' .. module 'sys' has no attribute 'getrefcount'" | |
Arguments: () | |
EXCEPTION '/home/tom/pypy/site-packages/astropy/io/fits/tests/data/checksum.fits' .. module 'sys' has no attribute 'getrefcount' | |
--- Logging error --- | |
Traceback (most recent call last): | |
File "/home/tom/Downloads/pypy3.6-7.2.0-linux_x86_64-portable/lib-python/3/logging/__init__.py", line 996, in emit | |
stream.write(msg) | |
ValueError: I/O operation on closed file | |
Call stack: | |
File "<string>", line 1, in <module> | |
File "/home/tom/pypy/site-packages/astropy/tests/runner.py", line 266, in test | |
return runner.run_tests(**kwargs) | |
File "/home/tom/pypy/site-packages/astropy/tests/runner.py", line 611, in run_tests | |
return super().run_tests(**kwargs) | |
File "/home/tom/pypy/site-packages/astropy/tests/runner.py", line 248, in run_tests | |
return pytest.main(args=args, plugins=plugins) | |
File "/home/tom/pypy/site-packages/_pytest/config/__init__.py", line 92, in main | |
config=config | |
File "/home/tom/pypy/site-packages/pluggy/hooks.py", line 286, in __call__ | |
return self._hookexec(self, self.get_hookimpls(), kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 93, in _hookexec | |
return self._inner_hookexec(hook, methods, kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 87, in <lambda> | |
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, | |
File "/home/tom/pypy/site-packages/pluggy/callers.py", line 187, in _multicall | |
res = hook_impl.function(*args) | |
File "/home/tom/pypy/site-packages/_pytest/main.py", line 239, in pytest_cmdline_main | |
return wrap_session(config, _main) | |
File "/home/tom/pypy/site-packages/_pytest/main.py", line 196, in wrap_session | |
session.exitstatus = doit(config, session) or 0 | |
File "/home/tom/pypy/site-packages/_pytest/main.py", line 246, in _main | |
config.hook.pytest_runtestloop(session=session) | |
File "/home/tom/pypy/site-packages/pluggy/hooks.py", line 286, in __call__ | |
return self._hookexec(self, self.get_hookimpls(), kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 93, in _hookexec | |
return self._inner_hookexec(hook, methods, kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 87, in <lambda> | |
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, | |
File "/home/tom/pypy/site-packages/pluggy/callers.py", line 187, in _multicall | |
res = hook_impl.function(*args) | |
File "/home/tom/pypy/site-packages/_pytest/main.py", line 270, in pytest_runtestloop | |
item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem) | |
File "/home/tom/pypy/site-packages/pluggy/hooks.py", line 286, in __call__ | |
return self._hookexec(self, self.get_hookimpls(), kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 93, in _hookexec | |
return self._inner_hookexec(hook, methods, kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 87, in <lambda> | |
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, | |
File "/home/tom/pypy/site-packages/pluggy/callers.py", line 187, in _multicall | |
res = hook_impl.function(*args) | |
File "/home/tom/pypy/site-packages/_pytest/runner.py", line 81, in pytest_runtest_protocol | |
runtestprotocol(item, nextitem=nextitem) | |
File "/home/tom/pypy/site-packages/_pytest/runner.py", line 96, in runtestprotocol | |
reports.append(call_and_report(item, "call", log)) | |
File "/home/tom/pypy/site-packages/_pytest/runner.py", line 182, in call_and_report | |
call = call_runtest_hook(item, when, **kwds) | |
File "/home/tom/pypy/site-packages/_pytest/runner.py", line 207, in call_runtest_hook | |
lambda: ihook(item=item, **kwds), when=when, reraise=reraise | |
File "/home/tom/pypy/site-packages/_pytest/runner.py", line 234, in from_call | |
result = func() | |
File "/home/tom/pypy/site-packages/_pytest/runner.py", line 207, in <lambda> | |
lambda: ihook(item=item, **kwds), when=when, reraise=reraise | |
File "/home/tom/pypy/site-packages/pluggy/hooks.py", line 286, in __call__ | |
return self._hookexec(self, self.get_hookimpls(), kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 93, in _hookexec | |
return self._inner_hookexec(hook, methods, kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 87, in <lambda> | |
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, | |
File "/home/tom/pypy/site-packages/pluggy/callers.py", line 187, in _multicall | |
res = hook_impl.function(*args) | |
File "/home/tom/pypy/site-packages/_pytest/runner.py", line 131, in pytest_runtest_call | |
item.runtest() | |
File "/home/tom/pypy/site-packages/_pytest/python.py", line 1435, in runtest | |
self.ihook.pytest_pyfunc_call(pyfuncitem=self) | |
File "/home/tom/pypy/site-packages/pluggy/hooks.py", line 286, in __call__ | |
return self._hookexec(self, self.get_hookimpls(), kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 93, in _hookexec | |
return self._inner_hookexec(hook, methods, kwargs) | |
File "/home/tom/pypy/site-packages/pluggy/manager.py", line 87, in <lambda> | |
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False, | |
File "/home/tom/pypy/site-packages/pluggy/callers.py", line 187, in _multicall | |
res = hook_impl.function(*args) | |
File "/home/tom/pypy/site-packages/_pytest/python.py", line 166, in pytest_pyfunc_call | |
result = testfunction(**testargs) | |
File "/home/tom/pypy/site-packages/astropy/io/fits/tests/test_fitscheck.py", line 23, in test_valid_file | |
assert fitscheck.main([testfile]) == 0 | |
File "/home/tom/pypy/site-packages/astropy/io/fits/scripts/fitscheck.py", line 215, in main | |
log.warning(f'{errors} errors') | |
Message: '1 errors' | |
Arguments: () | |
1 errors | |
------------------------------ Captured log call ------------------------------- | |
ERROR fitscheck:fitscheck.py:199 EXCEPTION '/home/tom/pypy/site-packages/astropy/io/fits/tests/data/checksum.fits' .. module 'sys' has no attribute 'getrefcount' | |
WARNING fitscheck:fitscheck.py:215 1 errors | |
_____________________ TestFitscheck.test_overwrite_invalid _____________________ | |
self = <astropy.io.fits.tests.test_fitscheck.TestFitscheck object at 0x000000000b8fd750> | |
capsys = <_pytest.capture.CaptureFixture object at 0x000000000b8fc138> | |
def test_overwrite_invalid(self, capsys): | |
""" | |
Tests that invalid checksum or datasum are overwriten when the file is | |
saved. | |
""" | |
reffile = self.temp('ref.fits') | |
with fits.open(self.data('tb.fits')) as hdul: | |
> hdul.writeto(reffile, checksum=True) | |
pypy/site-packages/astropy/io/fits/tests/test_fitscheck.py:56: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________________ TestFITSDiff_script.test_nodiff ________________________ | |
self = <astropy.io.fits.tests.test_fitsdiff.TestFITSDiff_script object at 0x000000000ade9520> | |
def test_nodiff(self): | |
a = np.arange(100).reshape(10, 10) | |
hdu_a = PrimaryHDU(data=a) | |
b = a.copy() | |
hdu_b = PrimaryHDU(data=b) | |
tmp_a = self.temp('testa.fits') | |
tmp_b = self.temp('testb.fits') | |
hdu_a.writeto(tmp_a) | |
hdu_b.writeto(tmp_b) | |
> numdiff = fitsdiff.main([tmp_a, tmp_b]) | |
pypy/site-packages/astropy/io/fits/tests/test_fitsdiff.py:40: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/scripts/fitsdiff.py:322: in main | |
ignore_blank_cards=opts.ignore_blank_cards) | |
pypy/site-packages/astropy/io/fits/diff.py:318: in __init__ | |
a.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________________ TestFITSDiff_script.test_onediff _______________________ | |
self = <astropy.io.fits.tests.test_fitsdiff.TestFITSDiff_script object at 0x0000000012a7d8d8> | |
def test_onediff(self): | |
a = np.arange(100).reshape(10, 10) | |
hdu_a = PrimaryHDU(data=a) | |
b = a.copy() | |
b[1, 0] = 12 | |
hdu_b = PrimaryHDU(data=b) | |
tmp_a = self.temp('testa.fits') | |
tmp_b = self.temp('testb.fits') | |
hdu_a.writeto(tmp_a) | |
hdu_b.writeto(tmp_b) | |
> numdiff = fitsdiff.main([tmp_a, tmp_b]) | |
pypy/site-packages/astropy/io/fits/tests/test_fitsdiff.py:53: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/scripts/fitsdiff.py:322: in main | |
ignore_blank_cards=opts.ignore_blank_cards) | |
pypy/site-packages/astropy/io/fits/diff.py:318: in __init__ | |
a.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________________ TestFITSDiff_script.test_manydiff _______________________ | |
self = <astropy.io.fits.tests.test_fitsdiff.TestFITSDiff_script object at 0x0000000018975fa0> | |
capsys = <_pytest.capture.CaptureFixture object at 0x0000000018974e90> | |
def test_manydiff(self, capsys): | |
a = np.arange(100).reshape(10, 10) | |
hdu_a = PrimaryHDU(data=a) | |
b = a + 1 | |
hdu_b = PrimaryHDU(data=b) | |
tmp_a = self.temp('testa.fits') | |
tmp_b = self.temp('testb.fits') | |
hdu_a.writeto(tmp_a) | |
hdu_b.writeto(tmp_b) | |
> numdiff = fitsdiff.main([tmp_a, tmp_b]) | |
pypy/site-packages/astropy/io/fits/tests/test_fitsdiff.py:66: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/scripts/fitsdiff.py:322: in main | |
ignore_blank_cards=opts.ignore_blank_cards) | |
pypy/site-packages/astropy/io/fits/diff.py:318: in __init__ | |
a.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________________ TestFITSDiff_script.test_outputfile ______________________ | |
self = <astropy.io.fits.tests.test_fitsdiff.TestFITSDiff_script object at 0x0000000013975168> | |
def test_outputfile(self): | |
a = np.arange(100).reshape(10, 10) | |
hdu_a = PrimaryHDU(data=a) | |
b = a.copy() | |
b[1, 0] = 12 | |
hdu_b = PrimaryHDU(data=b) | |
tmp_a = self.temp('testa.fits') | |
tmp_b = self.temp('testb.fits') | |
hdu_a.writeto(tmp_a) | |
hdu_b.writeto(tmp_b) | |
> numdiff = fitsdiff.main(['-o', self.temp('diff.txt'), tmp_a, tmp_b]) | |
pypy/site-packages/astropy/io/fits/tests/test_fitsdiff.py:95: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/scripts/fitsdiff.py:322: in main | |
ignore_blank_cards=opts.ignore_blank_cards) | |
pypy/site-packages/astropy/io/fits/diff.py:318: in __init__ | |
a.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________________ TestFITSDiff_script.test_atol _________________________ | |
self = <astropy.io.fits.tests.test_fitsdiff.TestFITSDiff_script object at 0x000000001ab0d600> | |
def test_atol(self): | |
a = np.arange(100, dtype=float).reshape(10, 10) | |
hdu_a = PrimaryHDU(data=a) | |
b = a.copy() | |
b[1, 0] = 11 | |
hdu_b = PrimaryHDU(data=b) | |
tmp_a = self.temp('testa.fits') | |
tmp_b = self.temp('testb.fits') | |
hdu_a.writeto(tmp_a) | |
hdu_b.writeto(tmp_b) | |
> numdiff = fitsdiff.main(["-a", "1", tmp_a, tmp_b]) | |
pypy/site-packages/astropy/io/fits/tests/test_fitsdiff.py:116: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/scripts/fitsdiff.py:322: in main | |
ignore_blank_cards=opts.ignore_blank_cards) | |
pypy/site-packages/astropy/io/fits/diff.py:318: in __init__ | |
a.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________________ TestFITSDiff_script.test_rtol _________________________ | |
self = <astropy.io.fits.tests.test_fitsdiff.TestFITSDiff_script object at 0x00000000170d8c28> | |
def test_rtol(self): | |
a = np.arange(100, dtype=float).reshape(10, 10) | |
hdu_a = PrimaryHDU(data=a) | |
b = a.copy() | |
b[1, 0] = 11 | |
hdu_b = PrimaryHDU(data=b) | |
tmp_a = self.temp('testa.fits') | |
tmp_b = self.temp('testb.fits') | |
hdu_a.writeto(tmp_a) | |
hdu_b.writeto(tmp_b) | |
> numdiff = fitsdiff.main(["-r", "1e-1", tmp_a, tmp_b]) | |
pypy/site-packages/astropy/io/fits/tests/test_fitsdiff.py:132: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/scripts/fitsdiff.py:322: in main | |
ignore_blank_cards=opts.ignore_blank_cards) | |
pypy/site-packages/astropy/io/fits/diff.py:318: in __init__ | |
a.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________________ TestFITSDiff_script.test_rtol_diff ______________________ | |
self = <astropy.io.fits.tests.test_fitsdiff.TestFITSDiff_script object at 0x0000000014c75ef8> | |
capsys = <_pytest.capture.CaptureFixture object at 0x0000000014c75b08> | |
def test_rtol_diff(self, capsys): | |
a = np.arange(100, dtype=float).reshape(10, 10) | |
hdu_a = PrimaryHDU(data=a) | |
b = a.copy() | |
b[1, 0] = 11 | |
hdu_b = PrimaryHDU(data=b) | |
tmp_a = self.temp('testa.fits') | |
tmp_b = self.temp('testb.fits') | |
hdu_a.writeto(tmp_a) | |
hdu_b.writeto(tmp_b) | |
> numdiff = fitsdiff.main(["-r", "1e-2", tmp_a, tmp_b]) | |
pypy/site-packages/astropy/io/fits/tests/test_fitsdiff.py:145: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/scripts/fitsdiff.py:322: in main | |
ignore_blank_cards=opts.ignore_blank_cards) | |
pypy/site-packages/astropy/io/fits/diff.py:318: in __init__ | |
a.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________________ TestFITSDiff_script.test_not_quiet ______________________ | |
self = <astropy.io.fits.tests.test_fitsdiff.TestFITSDiff_script object at 0x0000000015219248> | |
capsys = <_pytest.capture.CaptureFixture object at 0x00000000152186e8> | |
def test_not_quiet(self, capsys): | |
a = np.arange(100).reshape(10, 10) | |
hdu_a = PrimaryHDU(data=a) | |
b = a.copy() | |
hdu_b = PrimaryHDU(data=b) | |
tmp_a = self.temp('testa.fits') | |
tmp_b = self.temp('testb.fits') | |
hdu_a.writeto(tmp_a) | |
hdu_b.writeto(tmp_b) | |
> numdiff = fitsdiff.main([tmp_a, tmp_b]) | |
pypy/site-packages/astropy/io/fits/tests/test_fitsdiff.py:179: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/scripts/fitsdiff.py:322: in main | |
ignore_blank_cards=opts.ignore_blank_cards) | |
pypy/site-packages/astropy/io/fits/diff.py:318: in __init__ | |
a.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________________ TestFITSDiff_script.test_quiet ________________________ | |
self = <astropy.io.fits.tests.test_fitsdiff.TestFITSDiff_script object at 0x0000000010eb0f00> | |
capsys = <_pytest.capture.CaptureFixture object at 0x0000000010eb0ad8> | |
def test_quiet(self, capsys): | |
a = np.arange(100).reshape(10, 10) | |
hdu_a = PrimaryHDU(data=a) | |
b = a.copy() | |
hdu_b = PrimaryHDU(data=b) | |
tmp_a = self.temp('testa.fits') | |
tmp_b = self.temp('testb.fits') | |
hdu_a.writeto(tmp_a) | |
hdu_b.writeto(tmp_b) | |
> numdiff = fitsdiff.main(["-q", tmp_a, tmp_b]) | |
pypy/site-packages/astropy/io/fits/tests/test_fitsdiff.py:201: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/scripts/fitsdiff.py:322: in main | |
ignore_blank_cards=opts.ignore_blank_cards) | |
pypy/site-packages/astropy/io/fits/diff.py:318: in __init__ | |
a.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________________ TestFITSDiff_script.test_path _________________________ | |
self = <astropy.io.fits.tests.test_fitsdiff.TestFITSDiff_script object at 0x0000000013430090> | |
capsys = <_pytest.capture.CaptureFixture object at 0x00000000134935c8> | |
def test_path(self, capsys): | |
os.mkdir(self.temp('sub/')) | |
tmp_b = self.temp('sub/ascii.fits') | |
tmp_g = self.temp('sub/group.fits') | |
tmp_h = self.data('group.fits') | |
with hdulist.fitsopen(tmp_h) as hdu_b: | |
> hdu_b.writeto(tmp_g) | |
pypy/site-packages/astropy/io/fits/tests/test_fitsdiff.py:214: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________________ TestFITSDiff_script.test_ignore_hdus _____________________ | |
self = <astropy.io.fits.tests.test_fitsdiff.TestFITSDiff_script object at 0x0000000011ae0c60> | |
def test_ignore_hdus(self): | |
a = np.arange(100).reshape(10, 10) | |
b = a.copy() + 1 | |
ha = Header([('A', 1), ('B', 2), ('C', 3)]) | |
phdu_a = PrimaryHDU(header=ha) | |
phdu_b = PrimaryHDU(header=ha) | |
ihdu_a = ImageHDU(data=a, name='SCI') | |
ihdu_b = ImageHDU(data=b, name='SCI') | |
hdulist_a = HDUList([phdu_a, ihdu_a]) | |
hdulist_b = HDUList([phdu_b, ihdu_b]) | |
tmp_a = self.temp('testa.fits') | |
tmp_b = self.temp('testb.fits') | |
hdulist_a.writeto(tmp_a) | |
hdulist_b.writeto(tmp_b) | |
> numdiff = fitsdiff.main([tmp_a, tmp_b]) | |
pypy/site-packages/astropy/io/fits/tests/test_fitsdiff.py:263: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/scripts/fitsdiff.py:322: in main | |
ignore_blank_cards=opts.ignore_blank_cards) | |
pypy/site-packages/astropy/io/fits/diff.py:318: in __init__ | |
a.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________________ TestGroupsFunctions.test_open _________________________ | |
self = <astropy.io.fits.tests.test_groups.TestGroupsFunctions object at 0x000000000d699ad0> | |
def test_open(self): | |
with fits.open(self.data('random_groups.fits')) as hdul: | |
assert isinstance(hdul[0], fits.GroupsHDU) | |
naxes = (3, 1, 128, 1, 1) | |
parameters = ['UU', 'VV', 'WW', 'BASELINE', 'DATE'] | |
info = [(0, 'PRIMARY', 1, 'GroupsHDU', 147, naxes, 'float32', | |
'3 Groups 5 Parameters')] | |
assert hdul.info(output=False) == info | |
ghdu = hdul[0] | |
assert ghdu.parnames == parameters | |
assert list(ghdu.data.dtype.names) == parameters + ['DATA'] | |
assert isinstance(ghdu.data, fits.GroupData) | |
# The data should be equal to the number of groups | |
assert ghdu.header['GCOUNT'] == len(ghdu.data) | |
assert ghdu.data.data.shape == (len(ghdu.data),) + naxes[::-1] | |
assert ghdu.data.parnames == parameters | |
assert isinstance(ghdu.data[0], fits.Group) | |
assert len(ghdu.data[0]) == len(parameters) + 1 | |
assert ghdu.data[0].data.shape == naxes[::-1] | |
> assert ghdu.data[0].parnames == parameters | |
pypy/site-packages/astropy/io/fits/tests/test_groups.py:37: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________ TestGroupsFunctions.test_random_groups_data_update ______________ | |
self = <astropy.io.fits.tests.test_groups.TestGroupsFunctions object at 0x000000000b0bf638> | |
def test_random_groups_data_update(self): | |
""" | |
Regression test for https://github.com/astropy/astropy/issues/3730 and | |
for https://github.com/spacetelescope/PyFITS/issues/102 | |
""" | |
self.copy_file('random_groups.fits') | |
with fits.open(self.temp('random_groups.fits'), mode='update') as h: | |
> h[0].data['UU'] = 0.42 | |
pypy/site-packages/astropy/io/fits/tests/test_groups.py:70: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________ TestGroupsFunctions.test_parnames_round_trip _________________ | |
self = <astropy.io.fits.tests.test_groups.TestGroupsFunctions object at 0x00007f587b845088> | |
def test_parnames_round_trip(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/130 | |
Ensures that opening a random groups file in update mode or writing it | |
to a new file does not cause any change to the parameter names. | |
""" | |
# Because this test tries to update the random_groups.fits file, let's | |
# make a copy of it first (so that the file doesn't actually get | |
# modified in the off chance that the test fails | |
self.copy_file('random_groups.fits') | |
parameters = ['UU', 'VV', 'WW', 'BASELINE', 'DATE'] | |
with fits.open(self.temp('random_groups.fits'), mode='update') as h: | |
assert h[0].parnames == parameters | |
h.flush() | |
# Open again just in read-only mode to ensure the parnames didn't | |
# change | |
with fits.open(self.temp('random_groups.fits')) as h: | |
assert h[0].parnames == parameters | |
> h.writeto(self.temp('test.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_groups.py:96: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ TestGroupsFunctions.test_groupdata_slice ___________________ | |
self = <astropy.io.fits.tests.test_groups.TestGroupsFunctions object at 0x000000000b6a1050> | |
def test_groupdata_slice(self): | |
""" | |
A simple test to ensure that slicing GroupData returns a new, smaller | |
GroupData object, as is the case with a normal FITS_rec. This is a | |
regression test for an as-of-yet unreported issue where slicing | |
GroupData returned a single Group record. | |
""" | |
with fits.open(self.data('random_groups.fits')) as hdul: | |
s = hdul[0].data[1:] | |
assert isinstance(s, fits.GroupData) | |
assert len(s) == 2 | |
> assert hdul[0].data.parnames == s.parnames | |
pypy/site-packages/astropy/io/fits/tests/test_groups.py:113: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________________ TestGroupsFunctions.test_group_slice _____________________ | |
self = <astropy.io.fits.tests.test_groups.TestGroupsFunctions object at 0x000000000d3c7210> | |
def test_group_slice(self): | |
""" | |
Tests basic slicing a single group record. | |
""" | |
# A very basic slice test | |
with fits.open(self.data('random_groups.fits')) as hdul: | |
g = hdul[0].data[0] | |
s = g[2:4] | |
assert len(s) == 2 | |
assert s[0] == g[2] | |
assert s[-1] == g[-3] | |
s = g[::-1] | |
assert len(s) == 6 | |
assert (s[0] == g[-1]).all() | |
assert s[-1] == g[0] | |
s = g[::2] | |
assert len(s) == 3 | |
assert s[0] == g[0] | |
assert s[1] == g[2] | |
> assert s[2] == g[4] | |
pypy/site-packages/astropy/io/fits/tests/test_groups.py:135: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________________ TestGroupsFunctions.test_create_groupdata ___________________ | |
self = <astropy.io.fits.tests.test_groups.TestGroupsFunctions object at 0x000000000c2417c0> | |
def test_create_groupdata(self): | |
""" | |
Basic test for creating GroupData from scratch. | |
""" | |
imdata = np.arange(100.0) | |
imdata.shape = (10, 1, 1, 2, 5) | |
pdata1 = np.arange(10, dtype=np.float32) + 0.1 | |
pdata2 = 42.0 | |
x = fits.hdu.groups.GroupData(imdata, parnames=['abc', 'xyz'], | |
pardata=[pdata1, pdata2], bitpix=-32) | |
assert x.parnames == ['abc', 'xyz'] | |
assert (x.par('abc') == pdata1).all() | |
assert (x.par('xyz') == ([pdata2] * len(x))).all() | |
assert (x.data == imdata).all() | |
# Test putting the data into a GroupsHDU and round-tripping it | |
ghdu = fits.GroupsHDU(data=x) | |
assert ghdu.parnames == ['abc', 'xyz'] | |
assert ghdu.header['GCOUNT'] == 10 | |
ghdu.writeto(self.temp('test.fits')) | |
with fits.open(self.temp('test.fits')) as h: | |
hdr = h[0].header | |
assert hdr['GCOUNT'] == 10 | |
assert hdr['PCOUNT'] == 2 | |
assert hdr['NAXIS'] == 5 | |
assert hdr['NAXIS1'] == 0 | |
assert hdr['NAXIS2'] == 5 | |
assert hdr['NAXIS3'] == 2 | |
assert hdr['NAXIS4'] == 1 | |
assert hdr['NAXIS5'] == 1 | |
assert h[0].data.parnames == ['abc', 'xyz'] | |
> assert comparerecords(h[0].data, x) | |
pypy/site-packages/astropy/io/fits/tests/test_groups.py:171: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ TestHDUListFunctions.test_hdu_file_bytes ___________________ | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x000000001ec3c950> | |
def test_hdu_file_bytes(self): | |
with fits.open(self.data('checksum.fits')) as hdul: | |
res = hdul[0].filebytes() | |
assert res == 11520 | |
res = hdul[1].filebytes() | |
> assert res == 8640 | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:33: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________ TestHDUListFunctions.test_hdulist_file_info __________________ | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x0000000016b0ea30> | |
def test_hdulist_file_info(self): | |
def test_fileinfo(**kwargs): | |
assert res['datSpan'] == kwargs.get('datSpan', 2880) | |
assert res['resized'] == kwargs.get('resized', False) | |
assert res['filename'] == self.data('checksum.fits') | |
assert res['datLoc'] == kwargs.get('datLoc', 8640) | |
assert res['hdrLoc'] == kwargs.get('hdrLoc', 0) | |
assert res['filemode'] == 'readonly' | |
with fits.open(self.data('checksum.fits')) as hdul: | |
res = hdul.fileinfo(0) | |
res = hdul.fileinfo(1) | |
test_fileinfo(datLoc=17280, hdrLoc=11520) | |
hdu = fits.ImageHDU(data=hdul[0].data) | |
hdul.insert(1, hdu) | |
res = hdul.fileinfo(0) | |
test_fileinfo(resized=True) | |
res = hdul.fileinfo(1) | |
test_fileinfo(datSpan=None, resized=True, datLoc=None, hdrLoc=None) | |
res = hdul.fileinfo(2) | |
> test_fileinfo(resized=1, datLoc=17280, hdrLoc=11520) | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:60: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________ TestHDUListFunctions.test_append_table_extension_to_empty_list ________ | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x000000001090f8d8> | |
def test_append_table_extension_to_empty_list(self): | |
"""Tests appending a Simple Table ExtensionHDU to a empty HDUList.""" | |
hdul = fits.HDUList() | |
with fits.open(self.data('tb.fits')) as hdul1: | |
hdul.append(hdul1[1]) | |
info = [(0, 'PRIMARY', 1, 'PrimaryHDU', 4, (), '', ''), | |
(1, '', 1, 'BinTableHDU', 24, '2R x 4C', '[1J, 3A, 1E, 1L]', '')] | |
assert hdul.info(output=False) == info | |
> hdul.writeto(self.temp('test-append.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:110: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________ TestHDUListFunctions.test_append_primary_to_non_empty_list __________ | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x00000000160b4bb8> | |
def test_append_primary_to_non_empty_list(self): | |
"""Tests appending a Simple PrimaryHDU to a non-empty HDUList.""" | |
with fits.open(self.data('arange.fits')) as hdul: | |
hdu = fits.PrimaryHDU(np.arange(100, dtype=np.int32)) | |
hdul.append(hdu) | |
info = [(0, 'PRIMARY', 1, 'PrimaryHDU', 7, (11, 10, 7), 'int32', ''), | |
(1, '', 1, 'ImageHDU', 6, (100,), 'int32', '')] | |
assert hdul.info(output=False) == info | |
> hdul.writeto(self.temp('test-append.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:142: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________ TestHDUListFunctions.test_append_extension_to_non_empty_list _________ | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x0000000017076678> | |
def test_append_extension_to_non_empty_list(self): | |
"""Tests appending a Simple ExtensionHDU to a non-empty HDUList.""" | |
with fits.open(self.data('tb.fits')) as hdul: | |
hdul.append(hdul[1]) | |
info = [(0, 'PRIMARY', 1, 'PrimaryHDU', 11, (), '', ''), | |
(1, '', 1, 'BinTableHDU', 24, '2R x 4C', '[1J, 3A, 1E, 1L]', ''), | |
(2, '', 1, 'BinTableHDU', 24, '2R x 4C', '[1J, 3A, 1E, 1L]', '')] | |
assert hdul.info(output=False) == info | |
> hdul.writeto(self.temp('test-append.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:158: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________ TestHDUListFunctions.test_insert_table_extension_to_empty_list ________ | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x00000000163ff8d8> | |
def test_insert_table_extension_to_empty_list(self): | |
"""Tests inserting a Simple Table ExtensionHDU to a empty HDUList.""" | |
hdul = fits.HDUList() | |
with fits.open(self.data('tb.fits')) as hdul1: | |
hdul.insert(0, hdul1[1]) | |
info = [(0, 'PRIMARY', 1, 'PrimaryHDU', 4, (), '', ''), | |
(1, '', 1, 'BinTableHDU', 24, '2R x 4C', '[1J, 3A, 1E, 1L]', '')] | |
assert hdul.info(output=False) == info | |
> hdul.writeto(self.temp('test-insert.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:213: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________ TestHDUListFunctions.test_insert_primary_to_non_empty_list __________ | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x00000000168cfec0> | |
def test_insert_primary_to_non_empty_list(self): | |
"""Tests inserting a Simple PrimaryHDU to a non-empty HDUList.""" | |
with fits.open(self.data('arange.fits')) as hdul: | |
hdu = fits.PrimaryHDU(np.arange(100, dtype=np.int32)) | |
hdul.insert(1, hdu) | |
info = [(0, 'PRIMARY', 1, 'PrimaryHDU', 7, (11, 10, 7), 'int32', ''), | |
(1, '', 1, 'ImageHDU', 6, (100,), 'int32', '')] | |
assert hdul.info(output=False) == info | |
> hdul.writeto(self.temp('test-insert.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:245: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________ TestHDUListFunctions.test_insert_extension_to_non_empty_list _________ | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x000000000c9ec640> | |
def test_insert_extension_to_non_empty_list(self): | |
"""Tests inserting a Simple ExtensionHDU to a non-empty HDUList.""" | |
with fits.open(self.data('tb.fits')) as hdul: | |
hdul.insert(1, hdul[1]) | |
info = [(0, 'PRIMARY', 1, 'PrimaryHDU', 11, (), '', ''), | |
(1, '', 1, 'BinTableHDU', 24, '2R x 4C', '[1J, 3A, 1E, 1L]', ''), | |
(2, '', 1, 'BinTableHDU', 24, '2R x 4C', '[1J, 3A, 1E, 1L]', '')] | |
assert hdul.info(output=False) == info | |
> hdul.writeto(self.temp('test-insert.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:261: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___ TestHDUListFunctions.test_insert_extension_to_primary_in_non_empty_list ____ | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x00000000124a2410> | |
def test_insert_extension_to_primary_in_non_empty_list(self): | |
# Tests inserting a Simple ExtensionHDU to a non-empty HDUList. | |
with fits.open(self.data('tb.fits')) as hdul: | |
hdul.insert(0, hdul[1]) | |
info = [(0, 'PRIMARY', 1, 'PrimaryHDU', 4, (), '', ''), | |
(1, '', 1, 'BinTableHDU', 24, '2R x 4C', '[1J, 3A, 1E, 1L]', ''), | |
(2, '', 1, 'ImageHDU', 12, (), '', ''), | |
(3, '', 1, 'BinTableHDU', 24, '2R x 4C', '[1J, 3A, 1E, 1L]', '')] | |
assert hdul.info(output=False) == info | |
> hdul.writeto(self.temp('test-insert.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:312: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_ TestHDUListFunctions.test_insert_image_extension_to_primary_in_non_empty_list _ | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x00000000161a60c8> | |
def test_insert_image_extension_to_primary_in_non_empty_list(self): | |
""" | |
Tests inserting a Simple Image ExtensionHDU to a non-empty HDUList | |
as the primary HDU. | |
""" | |
with fits.open(self.data('tb.fits')) as hdul: | |
hdu = fits.ImageHDU(np.arange(100, dtype=np.int32)) | |
hdul.insert(0, hdu) | |
info = [(0, 'PRIMARY', 1, 'PrimaryHDU', 5, (100,), 'int32', ''), | |
(1, '', 1, 'ImageHDU', 12, (), '', ''), | |
(2, '', 1, 'BinTableHDU', 24, '2R x 4C', '[1J, 3A, 1E, 1L]', '')] | |
assert hdul.info(output=False) == info | |
> hdul.writeto(self.temp('test-insert.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:332: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________________ TestHDUListFunctions.test_update_filelike ___________________ | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x0000000022d771d8> | |
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) | |
sf.seek(0) | |
arr = np.zeros((200, 200)) | |
hdul = fits.open(sf, mode='update') | |
hdul[0].data = arr | |
> hdul.flush() | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:448: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/util.py:241: in wrapped | |
func(*args, **kwargs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:842: in flush | |
self._flush_update() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:1258: in _flush_update | |
self._flush_resize() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:1372: in _flush_resize | |
hdulist.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________ TestHDUListFunctions.test_replace_memmaped_array _______________ | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x0000000022199980> | |
def test_replace_memmaped_array(self): | |
# Copy the original before we modify it | |
with fits.open(self.data('test0.fits')) as hdul: | |
> hdul.writeto(self.temp('temp.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:543: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________ TestHDUListFunctions.test_open_file_with_end_padding _____________ | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x0000000011bc8758> | |
def test_open_file_with_end_padding(self): | |
"""Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/106 | |
Open files with end padding bytes. | |
""" | |
with fits.open(self.data('test0.fits'), | |
do_not_scale_image_data=True) as hdul: | |
info = hdul.info(output=False) | |
> hdul.writeto(self.temp('temp.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:562: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________ TestHDUListFunctions.test_open_file_with_bad_header_padding __________ | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x000000001f19cde8> | |
def test_open_file_with_bad_header_padding(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/136 | |
Open files with nulls for header block padding instead of spaces. | |
""" | |
a = np.arange(100).reshape(10, 10) | |
hdu = fits.PrimaryHDU(data=a) | |
hdu.writeto(self.temp('temp.fits')) | |
# Figure out where the header padding begins and fill it with nulls | |
end_card_pos = str(hdu.header).index('END' + ' ' * 77) | |
padding_start = end_card_pos + 80 | |
padding_len = 2880 - padding_start | |
with open(self.temp('temp.fits'), 'r+b') as f: | |
f.seek(padding_start) | |
f.write('\0'.encode('ascii') * padding_len) | |
with catch_warnings(AstropyUserWarning) as w: | |
with fits.open(self.temp('temp.fits')) as hdul: | |
> assert (hdul[0].data == a).all() | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:592: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________ TestHDUListFunctions.test_update_with_truncated_header ____________ | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x000000000b0bf8d8> | |
def test_update_with_truncated_header(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/148 | |
Test that saving an update where the header is shorter than the | |
original header doesn't leave a stump from the old header in the file. | |
""" | |
data = np.arange(100) | |
hdu = fits.PrimaryHDU(data=data) | |
idx = 1 | |
while len(hdu.header) < 34: | |
hdu.header[f'TEST{idx}'] = idx | |
idx += 1 | |
hdu.writeto(self.temp('temp.fits'), checksum=True) | |
with fits.open(self.temp('temp.fits'), mode='update') as hdul: | |
# Modify the header, forcing it to be rewritten | |
> hdul[0].header['TEST1'] = 2 | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:617: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________ TestHDUListFunctions.test_update_resized_header ________________ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000000c374678>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
> self.flush(output_verify=output_verify, verbose=verbose) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:963: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
args = ([<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000000c374678>],) | |
kwargs = {'output_verify': 'exception', 'verbose': False} | |
curr_thread = <_MainThread(MainThread, started 140018066300352)> | |
single_thread = True | |
SigintHandler = <class 'astropy.io.fits.util.ignore_sigint.<locals>.wrapped.<locals>.SigintHandler'> | |
sigint_handler = <astropy.io.fits.util.ignore_sigint.<locals>.wrapped.<locals>.SigintHandler object at 0x000000000c375088> | |
old_handler = <built-in function default_int_handler> | |
@wraps(func) | |
def wrapped(*args, **kwargs): | |
# Get the name of the current thread and determine if this is a single | |
# threaded application | |
curr_thread = threading.currentThread() | |
single_thread = (threading.activeCount() == 1 and | |
curr_thread.getName() == 'MainThread') | |
class SigintHandler: | |
def __init__(self): | |
self.sigint_received = False | |
def __call__(self, signum, frame): | |
warnings.warn('KeyboardInterrupt ignored until {} is ' | |
'complete!'.format(func.__name__), | |
AstropyUserWarning) | |
self.sigint_received = True | |
sigint_handler = SigintHandler() | |
# Define new signal interput handler | |
if single_thread: | |
# Install new handler | |
old_handler = signal.signal(signal.SIGINT, sigint_handler) | |
try: | |
> func(*args, **kwargs) | |
pypy/site-packages/astropy/io/fits/util.py:241: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000000c374678>] | |
output_verify = 'exception', verbose = False | |
@ignore_sigint | |
def flush(self, output_verify='fix', verbose=False): | |
""" | |
Force a write of the `HDUList` back to the file (for append and | |
update modes only). | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print verbose messages | |
""" | |
if self._file.mode not in ('append', 'update', 'ostream'): | |
warnings.warn("Flush for '{}' mode is not supported." | |
.format(self._file.mode), AstropyUserWarning) | |
return | |
if self._save_backup and self._file.mode in ('append', 'update'): | |
filename = self._file.name | |
if os.path.exists(filename): | |
# The the file doesn't actually exist anymore for some reason | |
# then there's no point in trying to make a backup | |
backup = filename + '.bak' | |
idx = 1 | |
while os.path.exists(backup): | |
backup = filename + '.bak.' + str(idx) | |
idx += 1 | |
warnings.warn('Saving a backup of {} to {}.'.format( | |
filename, backup), AstropyUserWarning) | |
try: | |
shutil.copy(filename, backup) | |
except OSError as exc: | |
raise OSError('Failed to save backup to destination {}: ' | |
'{}'.format(filename, exc)) | |
self.verify(option=output_verify) | |
if self._file.mode in ('append', 'ostream'): | |
for hdu in self: | |
if verbose: | |
try: | |
extver = str(hdu._header['extver']) | |
except KeyError: | |
extver = '' | |
# only append HDU's which are "new" | |
if hdu._new: | |
hdu._prewriteto(checksum=hdu._output_checksum) | |
with _free_space_check(self): | |
hdu._writeto(self._file) | |
if verbose: | |
print('append HDU', hdu.name, extver) | |
hdu._new = False | |
hdu._postwriteto() | |
elif self._file.mode == 'update': | |
> self._flush_update() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:842: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000000c374678>] | |
def _flush_update(self): | |
"""Implements flushing changes to a file in update mode.""" | |
for hdu in self: | |
# Need to all _prewriteto() for each HDU first to determine if | |
# resizing will be necessary | |
hdu._prewriteto(checksum=hdu._output_checksum, inplace=True) | |
try: | |
self._wasresized() | |
# if the HDUList is resized, need to write out the entire contents of | |
# the hdulist to the file. | |
if self._resize or self._file.compression: | |
> self._flush_resize() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:1258: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000000c374678>] | |
def _flush_resize(self): | |
""" | |
Implements flushing changes in update mode when parts of one or more HDU | |
need to be resized. | |
""" | |
old_name = self._file.name | |
old_memmap = self._file.memmap | |
name = _tmp_name(old_name) | |
if not self._file.file_like: | |
old_mode = os.stat(old_name).st_mode | |
# The underlying file is an actual file object. The HDUList is | |
# resized, so we need to write it to a tmp file, delete the | |
# original file, and rename the tmp file to the original file. | |
if self._file.compression == 'gzip': | |
new_file = gzip.GzipFile(name, mode='ab+') | |
elif self._file.compression == 'bzip2': | |
if not HAS_BZ2: | |
raise ModuleNotFoundError( | |
"This Python installation does not provide the bz2 module.") | |
new_file = bz2.BZ2File(name, mode='w') | |
else: | |
new_file = name | |
with self.fromfile(new_file, mode='append') as hdulist: | |
for hdu in self: | |
hdu._writeto(hdulist._file, inplace=True, copy=True) | |
if sys.platform.startswith('win'): | |
# Collect a list of open mmaps to the data; this well be | |
# used later. See below. | |
mmaps = [(idx, _get_array_mmap(hdu.data), hdu.data) | |
for idx, hdu in enumerate(self) if hdu._has_data] | |
hdulist._file.close() | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:1307: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x000000000c2ad440> | |
@pytest.mark.filterwarnings("ignore:Assigning the 'data' attribute is an " | |
"inherently unsafe operation") | |
def test_update_resized_header(self): | |
""" | |
Test saving updates to a file where the header is one block smaller | |
than before, and in the case where the heade ris one block larger than | |
before. | |
""" | |
data = np.arange(100) | |
hdu = fits.PrimaryHDU(data=data) | |
idx = 1 | |
while len(str(hdu.header)) <= 2880: | |
hdu.header[f'TEST{idx}'] = idx | |
idx += 1 | |
orig_header = hdu.header.copy() | |
hdu.writeto(self.temp('temp.fits')) | |
with fits.open(self.temp('temp.fits'), mode='update') as hdul: | |
while len(str(hdul[0].header)) > 2880: | |
> del hdul[0].header[-1] | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:645: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________ TestHDUListFunctions.test_update_resized_header2 _______________ | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x00000000203cf8a0> | |
def test_update_resized_header2(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/150 | |
This is similar to test_update_resized_header, but specifically tests a | |
case of multiple consecutive flush() calls on the same HDUList object, | |
where each flush() requires a resize. | |
""" | |
data1 = np.arange(100) | |
data2 = np.arange(100) + 100 | |
phdu = fits.PrimaryHDU(data=data1) | |
hdu = fits.ImageHDU(data=data2) | |
phdu.writeto(self.temp('temp.fits')) | |
with fits.open(self.temp('temp.fits'), mode='append') as hdul: | |
hdul.append(hdu) | |
with fits.open(self.temp('temp.fits'), mode='update') as hdul: | |
idx = 1 | |
while len(str(hdul[0].header)) <= 2880 * 2: | |
hdul[0].header[f'TEST{idx}'] = idx | |
idx += 1 | |
> hdul.flush() | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:688: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
args = ([<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000020529168>, <astropy.io.fits.hdu.image.ImageHDU object at 0x0000000020529f68>],) | |
kwargs = {}, curr_thread = <_MainThread(MainThread, started 140018066300352)> | |
single_thread = True | |
SigintHandler = <class 'astropy.io.fits.util.ignore_sigint.<locals>.wrapped.<locals>.SigintHandler'> | |
sigint_handler = <astropy.io.fits.util.ignore_sigint.<locals>.wrapped.<locals>.SigintHandler object at 0x0000000020529e50> | |
old_handler = <built-in function default_int_handler> | |
@wraps(func) | |
def wrapped(*args, **kwargs): | |
# Get the name of the current thread and determine if this is a single | |
# threaded application | |
curr_thread = threading.currentThread() | |
single_thread = (threading.activeCount() == 1 and | |
curr_thread.getName() == 'MainThread') | |
class SigintHandler: | |
def __init__(self): | |
self.sigint_received = False | |
def __call__(self, signum, frame): | |
warnings.warn('KeyboardInterrupt ignored until {} is ' | |
'complete!'.format(func.__name__), | |
AstropyUserWarning) | |
self.sigint_received = True | |
sigint_handler = SigintHandler() | |
# Define new signal interput handler | |
if single_thread: | |
# Install new handler | |
old_handler = signal.signal(signal.SIGINT, sigint_handler) | |
try: | |
> func(*args, **kwargs) | |
pypy/site-packages/astropy/io/fits/util.py:241: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000020529168>, <astropy.io.fits.hdu.image.ImageHDU object at 0x0000000020529f68>] | |
output_verify = 'fix', verbose = False | |
@ignore_sigint | |
def flush(self, output_verify='fix', verbose=False): | |
""" | |
Force a write of the `HDUList` back to the file (for append and | |
update modes only). | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print verbose messages | |
""" | |
if self._file.mode not in ('append', 'update', 'ostream'): | |
warnings.warn("Flush for '{}' mode is not supported." | |
.format(self._file.mode), AstropyUserWarning) | |
return | |
if self._save_backup and self._file.mode in ('append', 'update'): | |
filename = self._file.name | |
if os.path.exists(filename): | |
# The the file doesn't actually exist anymore for some reason | |
# then there's no point in trying to make a backup | |
backup = filename + '.bak' | |
idx = 1 | |
while os.path.exists(backup): | |
backup = filename + '.bak.' + str(idx) | |
idx += 1 | |
warnings.warn('Saving a backup of {} to {}.'.format( | |
filename, backup), AstropyUserWarning) | |
try: | |
shutil.copy(filename, backup) | |
except OSError as exc: | |
raise OSError('Failed to save backup to destination {}: ' | |
'{}'.format(filename, exc)) | |
self.verify(option=output_verify) | |
if self._file.mode in ('append', 'ostream'): | |
for hdu in self: | |
if verbose: | |
try: | |
extver = str(hdu._header['extver']) | |
except KeyError: | |
extver = '' | |
# only append HDU's which are "new" | |
if hdu._new: | |
hdu._prewriteto(checksum=hdu._output_checksum) | |
with _free_space_check(self): | |
hdu._writeto(self._file) | |
if verbose: | |
print('append HDU', hdu.name, extver) | |
hdu._new = False | |
hdu._postwriteto() | |
elif self._file.mode == 'update': | |
> self._flush_update() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:842: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000020529168>, <astropy.io.fits.hdu.image.ImageHDU object at 0x0000000020529f68>] | |
def _flush_update(self): | |
"""Implements flushing changes to a file in update mode.""" | |
for hdu in self: | |
# Need to all _prewriteto() for each HDU first to determine if | |
# resizing will be necessary | |
hdu._prewriteto(checksum=hdu._output_checksum, inplace=True) | |
try: | |
self._wasresized() | |
# if the HDUList is resized, need to write out the entire contents of | |
# the hdulist to the file. | |
if self._resize or self._file.compression: | |
> self._flush_resize() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:1258: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000020529168>, <astropy.io.fits.hdu.image.ImageHDU object at 0x0000000020529f68>] | |
def _flush_resize(self): | |
""" | |
Implements flushing changes in update mode when parts of one or more HDU | |
need to be resized. | |
""" | |
old_name = self._file.name | |
old_memmap = self._file.memmap | |
name = _tmp_name(old_name) | |
if not self._file.file_like: | |
old_mode = os.stat(old_name).st_mode | |
# The underlying file is an actual file object. The HDUList is | |
# resized, so we need to write it to a tmp file, delete the | |
# original file, and rename the tmp file to the original file. | |
if self._file.compression == 'gzip': | |
new_file = gzip.GzipFile(name, mode='ab+') | |
elif self._file.compression == 'bzip2': | |
if not HAS_BZ2: | |
raise ModuleNotFoundError( | |
"This Python installation does not provide the bz2 module.") | |
new_file = bz2.BZ2File(name, mode='w') | |
else: | |
new_file = name | |
with self.fromfile(new_file, mode='append') as hdulist: | |
for hdu in self: | |
hdu._writeto(hdulist._file, inplace=True, copy=True) | |
if sys.platform.startswith('win'): | |
# Collect a list of open mmaps to the data; this well be | |
# used later. See below. | |
mmaps = [(idx, _get_array_mmap(hdu.data), hdu.data) | |
for idx, hdu in enumerate(self) if hdu._has_data] | |
hdulist._file.close() | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:1307: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000020529168>, <astropy.io.fits.hdu.image.ImageHDU object at 0x0000000020529f68>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
> self.flush(output_verify=output_verify, verbose=verbose) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:963: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
args = ([<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000020529168>, <astropy.io.fits.hdu.image.ImageHDU object at 0x0000000020529f68>],) | |
kwargs = {'output_verify': 'exception', 'verbose': False} | |
curr_thread = <_MainThread(MainThread, started 140018066300352)> | |
single_thread = True | |
SigintHandler = <class 'astropy.io.fits.util.ignore_sigint.<locals>.wrapped.<locals>.SigintHandler'> | |
sigint_handler = <astropy.io.fits.util.ignore_sigint.<locals>.wrapped.<locals>.SigintHandler object at 0x00000000205eaaa0> | |
old_handler = <built-in function default_int_handler> | |
@wraps(func) | |
def wrapped(*args, **kwargs): | |
# Get the name of the current thread and determine if this is a single | |
# threaded application | |
curr_thread = threading.currentThread() | |
single_thread = (threading.activeCount() == 1 and | |
curr_thread.getName() == 'MainThread') | |
class SigintHandler: | |
def __init__(self): | |
self.sigint_received = False | |
def __call__(self, signum, frame): | |
warnings.warn('KeyboardInterrupt ignored until {} is ' | |
'complete!'.format(func.__name__), | |
AstropyUserWarning) | |
self.sigint_received = True | |
sigint_handler = SigintHandler() | |
# Define new signal interput handler | |
if single_thread: | |
# Install new handler | |
old_handler = signal.signal(signal.SIGINT, sigint_handler) | |
try: | |
> func(*args, **kwargs) | |
pypy/site-packages/astropy/io/fits/util.py:241: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000020529168>, <astropy.io.fits.hdu.image.ImageHDU object at 0x0000000020529f68>] | |
output_verify = 'exception', verbose = False | |
@ignore_sigint | |
def flush(self, output_verify='fix', verbose=False): | |
""" | |
Force a write of the `HDUList` back to the file (for append and | |
update modes only). | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print verbose messages | |
""" | |
if self._file.mode not in ('append', 'update', 'ostream'): | |
warnings.warn("Flush for '{}' mode is not supported." | |
.format(self._file.mode), AstropyUserWarning) | |
return | |
if self._save_backup and self._file.mode in ('append', 'update'): | |
filename = self._file.name | |
if os.path.exists(filename): | |
# The the file doesn't actually exist anymore for some reason | |
# then there's no point in trying to make a backup | |
backup = filename + '.bak' | |
idx = 1 | |
while os.path.exists(backup): | |
backup = filename + '.bak.' + str(idx) | |
idx += 1 | |
warnings.warn('Saving a backup of {} to {}.'.format( | |
filename, backup), AstropyUserWarning) | |
try: | |
shutil.copy(filename, backup) | |
except OSError as exc: | |
raise OSError('Failed to save backup to destination {}: ' | |
'{}'.format(filename, exc)) | |
self.verify(option=output_verify) | |
if self._file.mode in ('append', 'ostream'): | |
for hdu in self: | |
if verbose: | |
try: | |
extver = str(hdu._header['extver']) | |
except KeyError: | |
extver = '' | |
# only append HDU's which are "new" | |
if hdu._new: | |
hdu._prewriteto(checksum=hdu._output_checksum) | |
with _free_space_check(self): | |
hdu._writeto(self._file) | |
if verbose: | |
print('append HDU', hdu.name, extver) | |
hdu._new = False | |
hdu._postwriteto() | |
elif self._file.mode == 'update': | |
> self._flush_update() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:842: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000020529168>, <astropy.io.fits.hdu.image.ImageHDU object at 0x0000000020529f68>] | |
def _flush_update(self): | |
"""Implements flushing changes to a file in update mode.""" | |
for hdu in self: | |
# Need to all _prewriteto() for each HDU first to determine if | |
# resizing will be necessary | |
hdu._prewriteto(checksum=hdu._output_checksum, inplace=True) | |
try: | |
self._wasresized() | |
# if the HDUList is resized, need to write out the entire contents of | |
# the hdulist to the file. | |
if self._resize or self._file.compression: | |
> self._flush_resize() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:1258: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000020529168>, <astropy.io.fits.hdu.image.ImageHDU object at 0x0000000020529f68>] | |
def _flush_resize(self): | |
""" | |
Implements flushing changes in update mode when parts of one or more HDU | |
need to be resized. | |
""" | |
old_name = self._file.name | |
old_memmap = self._file.memmap | |
name = _tmp_name(old_name) | |
if not self._file.file_like: | |
old_mode = os.stat(old_name).st_mode | |
# The underlying file is an actual file object. The HDUList is | |
# resized, so we need to write it to a tmp file, delete the | |
# original file, and rename the tmp file to the original file. | |
if self._file.compression == 'gzip': | |
new_file = gzip.GzipFile(name, mode='ab+') | |
elif self._file.compression == 'bzip2': | |
if not HAS_BZ2: | |
raise ModuleNotFoundError( | |
"This Python installation does not provide the bz2 module.") | |
new_file = bz2.BZ2File(name, mode='w') | |
else: | |
new_file = name | |
with self.fromfile(new_file, mode='append') as hdulist: | |
for hdu in self: | |
> hdu._writeto(hdulist._file, inplace=True, copy=True) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:1299: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000020529168> | |
fileobj = <astropy.io.fits.file._File <_io.FileIO [closed]>>, inplace = True | |
copy = True | |
def _writeto(self, fileobj, inplace=False, copy=False): | |
try: | |
dirname = os.path.dirname(fileobj._file.name) | |
except (AttributeError, TypeError): | |
dirname = None | |
with _free_space_check(self, dirname): | |
> self._writeto_internal(fileobj, inplace, copy) | |
pypy/site-packages/astropy/io/fits/hdu/base.py:674: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000020529168> | |
fileobj = <astropy.io.fits.file._File <_io.FileIO [closed]>>, inplace = True | |
copy = True | |
def _writeto_internal(self, fileobj, inplace, copy): | |
# 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) | |
# Set the various data location attributes on newly-written HDUs | |
if self._new: | |
self._header_offset = header_offset | |
self._data_offset = data_offset | |
self._data_size = data_size | |
return | |
hdrloc = self._header_offset | |
hdrsize = self._data_offset - self._header_offset | |
datloc = self._data_offset | |
datsize = self._data_size | |
if self._header._modified: | |
# Seek to the original header location in the file | |
> self._file.seek(hdrloc) | |
pypy/site-packages/astropy/io/fits/hdu/base.py:696: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, offset = 0 | |
whence = 0 | |
def seek(self, offset, whence=0): | |
if not hasattr(self._file, 'seek'): | |
return | |
> self._file.seek(offset, whence) | |
E ValueError: I/O operation on closed file | |
pypy/site-packages/astropy/io/fits/file.py:389: ValueError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x00000000203cf8a0> | |
def test_update_resized_header2(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/150 | |
This is similar to test_update_resized_header, but specifically tests a | |
case of multiple consecutive flush() calls on the same HDUList object, | |
where each flush() requires a resize. | |
""" | |
data1 = np.arange(100) | |
data2 = np.arange(100) + 100 | |
phdu = fits.PrimaryHDU(data=data1) | |
hdu = fits.ImageHDU(data=data2) | |
phdu.writeto(self.temp('temp.fits')) | |
with fits.open(self.temp('temp.fits'), mode='append') as hdul: | |
hdul.append(hdu) | |
with fits.open(self.temp('temp.fits'), mode='update') as hdul: | |
idx = 1 | |
while len(str(hdul[0].header)) <= 2880 * 2: | |
hdul[0].header[f'TEST{idx}'] = idx | |
idx += 1 | |
hdul.flush() | |
> hdul.append(hdu) | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:689: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________________ TestHDUListFunctions.test_hdul_fromstring ___________________ | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x000000000d566fa8> | |
@ignore_warnings() | |
def test_hdul_fromstring(self): | |
""" | |
Test creating the HDUList structure in memory from a string containing | |
an entire FITS file. This is similar to test_hdu_fromstring but for an | |
entire multi-extension FITS file at once. | |
""" | |
# Tests HDUList.fromstring for all of Astropy's built in test files | |
def test_fromstring(filename): | |
with fits.open(filename) as hdul: | |
orig_info = hdul.info(output=False) | |
with open(filename, 'rb') as f: | |
dat = f.read() | |
hdul2 = fits.HDUList.fromstring(dat) | |
assert orig_info == hdul2.info(output=False) | |
for idx in range(len(hdul)): | |
assert hdul[idx].header == hdul2[idx].header | |
if hdul[idx].data is None or hdul2[idx].data is None: | |
assert hdul[idx].data == hdul2[idx].data | |
elif (hdul[idx].data.dtype.fields and | |
hdul2[idx].data.dtype.fields): | |
# Compare tables | |
for n in hdul[idx].data.names: | |
c1 = hdul[idx].data[n] | |
c2 = hdul2[idx].data[n] | |
assert (c1 == c2).all() | |
elif (any(dim == 0 for dim in hdul[idx].data.shape) or | |
any(dim == 0 for dim in hdul2[idx].data.shape)): | |
# For some reason some combinations of Python and Numpy | |
# on Windows result in MemoryErrors when trying to work | |
# on memmap arrays with more than one dimension but | |
# some dimensions of size zero, so include a special | |
# case for that | |
return hdul[idx].data.shape == hdul2[idx].data.shape | |
else: | |
np.testing.assert_array_equal(hdul[idx].data, | |
hdul2[idx].data) | |
for filename in glob.glob(os.path.join(self.data_dir, '*.fits')): | |
if sys.platform == 'win32' and filename == 'zerowidth.fits': | |
# Running this test on this file causes a crash in some | |
# versions of Numpy on Windows. See ticket: | |
# https://aeon.stsci.edu/ssb/trac/pyfits/ticket/174 | |
continue | |
elif filename.endswith('variable_length_table.fits'): | |
# Comparing variable length arrays is non-trivial and thus | |
# skipped at this point. | |
# TODO: That's probably possible, so one could make it work. | |
continue | |
> test_fromstring(filename) | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:749: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:736: in test_fromstring | |
hdul2[idx].data) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________________ TestHDUListFunctions.test_save_backup _____________________ | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x000000001451b050> | |
def test_save_backup(self): | |
"""Test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/121 | |
Save backup of file before flushing changes. | |
""" | |
self.copy_file('scale.fits') | |
with ignore_warnings(): | |
with fits.open(self.temp('scale.fits'), mode='update', | |
save_backup=True) as hdul: | |
# Make some changes to the original file to force its header | |
# and data to be rewritten | |
hdul[0].header['TEST'] = 'TEST' | |
> hdul[0].data[0] = 0 | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:768: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________ TestHDUListFunctions.test_replace_mmap_data __________________ | |
mmap_a = True, mmap_b = True | |
def test(mmap_a, mmap_b): | |
hdu_a = fits.PrimaryHDU(data=arr_a) | |
hdu_a.writeto(self.temp('test_a.fits'), overwrite=True) | |
hdu_b = fits.PrimaryHDU(data=arr_b) | |
hdu_b.writeto(self.temp('test_b.fits'), overwrite=True) | |
with fits.open(self.temp('test_a.fits'), mode='update', | |
memmap=mmap_a) as hdul_a: | |
with fits.open(self.temp('test_b.fits'), | |
memmap=mmap_b) as hdul_b: | |
> hdul_a[0].data = hdul_b[0].data | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:809: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000013e3ec60>] | |
type = None, value = None, traceback = None | |
def __exit__(self, type, value, traceback): | |
> self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000013e3ec60>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
self.flush(output_verify=output_verify, verbose=verbose) | |
finally: | |
if self._file and closed and hasattr(self._file, 'close'): | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x0000000018c59948> | |
def test_replace_mmap_data(self): | |
"""Regression test for | |
https://github.com/spacetelescope/PyFITS/issues/25 | |
Replacing the mmap'd data of one file with mmap'd data from a | |
different file should work. | |
""" | |
arr_a = np.arange(10) | |
arr_b = arr_a * 2 | |
def test(mmap_a, mmap_b): | |
hdu_a = fits.PrimaryHDU(data=arr_a) | |
hdu_a.writeto(self.temp('test_a.fits'), overwrite=True) | |
hdu_b = fits.PrimaryHDU(data=arr_b) | |
hdu_b.writeto(self.temp('test_b.fits'), overwrite=True) | |
with fits.open(self.temp('test_a.fits'), mode='update', | |
memmap=mmap_a) as hdul_a: | |
with fits.open(self.temp('test_b.fits'), | |
memmap=mmap_b) as hdul_b: | |
hdul_a[0].data = hdul_b[0].data | |
with fits.open(self.temp('test_a.fits')) as hdul_a: | |
assert np.all(hdul_a[0].data == arr_b) | |
with ignore_warnings(): | |
> test(True, True) | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:815: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:809: in test | |
hdul_a[0].data = hdul_b[0].data | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:970: in close | |
hdu._close(closed=closed) | |
pypy/site-packages/astropy/io/fits/hdu/base.py:748: in _close | |
del self.data | |
pypy/site-packages/astropy/utils/decorators.py:765: in __delete__ | |
self.fdel(obj) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000013e3e8e0> | |
def data(self): | |
# The deleter | |
if self._file is not None and self._data_loaded: | |
> data_refcount = sys.getrefcount(self.data) | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/hdu/base.py:117: AttributeError | |
________________ TestHDUListFunctions.test_replace_mmap_data_2 _________________ | |
mmap_a = True, mmap_b = True | |
def test(mmap_a, mmap_b): | |
col_a = fits.Column(name='a', format='J', array=arr_a) | |
col_b = fits.Column(name='b', format='J', array=arr_b) | |
hdu_a = fits.BinTableHDU.from_columns([col_a]) | |
hdu_a.writeto(self.temp('test_a.fits'), overwrite=True) | |
hdu_b = fits.BinTableHDU.from_columns([col_b]) | |
hdu_b.writeto(self.temp('test_b.fits'), overwrite=True) | |
with fits.open(self.temp('test_a.fits'), mode='update', | |
memmap=mmap_a) as hdul_a: | |
with fits.open(self.temp('test_b.fits'), | |
memmap=mmap_b) as hdul_b: | |
> hdul_a[1].data = hdul_b[1].data | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:847: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x00000000220f78a0>, <astropy.io.fits.hdu.table.BinTableHDU object at 0x00000000220f6c60>] | |
type = None, value = None, traceback = None | |
def __exit__(self, type, value, traceback): | |
> self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x00000000220f78a0>, <astropy.io.fits.hdu.table.BinTableHDU object at 0x00000000220f6c60>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
self.flush(output_verify=output_verify, verbose=verbose) | |
finally: | |
if self._file and closed and hasattr(self._file, 'close'): | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_hdulist.TestHDUListFunctions object at 0x00000000134b6790> | |
def test_replace_mmap_data_2(self): | |
"""Regression test for | |
https://github.com/spacetelescope/PyFITS/issues/25 | |
Replacing the mmap'd data of one file with mmap'd data from a | |
different file should work. Like test_replace_mmap_data but with | |
table data instead of image data. | |
""" | |
arr_a = np.arange(10) | |
arr_b = arr_a * 2 | |
def test(mmap_a, mmap_b): | |
col_a = fits.Column(name='a', format='J', array=arr_a) | |
col_b = fits.Column(name='b', format='J', array=arr_b) | |
hdu_a = fits.BinTableHDU.from_columns([col_a]) | |
hdu_a.writeto(self.temp('test_a.fits'), overwrite=True) | |
hdu_b = fits.BinTableHDU.from_columns([col_b]) | |
hdu_b.writeto(self.temp('test_b.fits'), overwrite=True) | |
with fits.open(self.temp('test_a.fits'), mode='update', | |
memmap=mmap_a) as hdul_a: | |
with fits.open(self.temp('test_b.fits'), | |
memmap=mmap_b) as hdul_b: | |
hdul_a[1].data = hdul_b[1].data | |
with fits.open(self.temp('test_a.fits')) as hdul_a: | |
assert 'b' in hdul_a[1].columns.names | |
assert 'a' not in hdul_a[1].columns.names | |
assert np.all(hdul_a[1].data['b'] == arr_b) | |
with ignore_warnings(): | |
> test(True, True) | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:855: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py:847: in test | |
hdul_a[1].data = hdul_b[1].data | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:970: in close | |
hdu._close(closed=closed) | |
pypy/site-packages/astropy/io/fits/hdu/base.py:748: in _close | |
del self.data | |
pypy/site-packages/astropy/utils/decorators.py:765: in __delete__ | |
self.fdel(obj) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.hdu.table.BinTableHDU object at 0x00000000220f6de8> | |
def data(self): | |
# The deleter | |
if self._file is not None and self._data_loaded: | |
> data_refcount = sys.getrefcount(self.data) | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/hdu/base.py:117: AttributeError | |
___________________ TestHeaderFunctions.test_update_comment ____________________ | |
self = <astropy.io.fits.tests.test_header.TestHeaderFunctions object at 0x0000000016179fa0> | |
def test_update_comment(self): | |
hdul = fits.open(self.data('arange.fits')) | |
hdul[0].header.update({'FOO': ('BAR', 'BAZ')}) | |
assert hdul[0].header['FOO'] == 'BAR' | |
assert hdul[0].header.comments['FOO'] == 'BAZ' | |
with pytest.raises(ValueError): | |
hdul[0].header.update({'FOO2': ('BAR', 'BAZ', 'EXTRA')}) | |
hdul.writeto(self.temp('test.fits')) | |
> hdul.close() | |
pypy/site-packages/astropy/io/fits/tests/test_header.py:248: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ TestHeaderFunctions.test_end_in_comment ____________________ | |
self = <astropy.io.fits.tests.test_header.TestHeaderFunctions object at 0x0000000011aea368> | |
def test_end_in_comment(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/142 | |
Tests a case where the comment of a card ends with END, and is followed | |
by several blank cards. | |
""" | |
data = np.arange(100).reshape(10, 10) | |
hdu = fits.PrimaryHDU(data=data) | |
hdu.header['TESTKW'] = ('Test val', 'This is the END') | |
# Add a couple blanks after the END string | |
hdu.header.append() | |
hdu.header.append() | |
hdu.writeto(self.temp('test.fits')) | |
with fits.open(self.temp('test.fits'), memmap=False) as hdul: | |
# memmap = False to avoid leaving open a mmap to the file when we | |
# access the data--this causes problems on Windows when we try to | |
# overwrite the file later | |
assert 'TESTKW' in hdul[0].header | |
assert hdul[0].header == hdu.header | |
assert (hdul[0].data == data).all() | |
# Add blanks until the header is extended to two block sizes | |
while len(hdu.header) < 36: | |
hdu.header.append() | |
with ignore_warnings(): | |
hdu.writeto(self.temp('test.fits'), overwrite=True) | |
with fits.open(self.temp('test.fits')) as hdul: | |
assert 'TESTKW' in hdul[0].header | |
assert hdul[0].header == hdu.header | |
> assert (hdul[0].data == data).all() | |
pypy/site-packages/astropy/io/fits/tests/test_header.py:2023: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________________ TestImageFunctions.test_fortran_array _____________________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x0000000022716838> | |
def test_fortran_array(self): | |
# Test that files are being correctly written+read for "C" and "F" order arrays | |
a = np.arange(21).reshape(3,7) | |
b = np.asfortranarray(a) | |
afits = self.temp('a_str.fits') | |
bfits = self.temp('b_str.fits') | |
# writting to str specified files | |
fits.PrimaryHDU(data=a).writeto(afits) | |
fits.PrimaryHDU(data=b).writeto(bfits) | |
> np.testing.assert_array_equal(fits.getdata(afits), a) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:178: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/convenience.py:204: in getdata | |
hdulist.close(closed=closed) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________ TestImageFunctions.test_fortran_array_non_contiguous _____________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x000000001aa90288> | |
def test_fortran_array_non_contiguous(self): | |
# Test that files are being correctly written+read for 'C' and 'F' order arrays | |
a = np.arange(105).reshape(3,5,7) | |
b = np.asfortranarray(a) | |
# writting to str specified files | |
afits = self.temp('a_str_slice.fits') | |
bfits = self.temp('b_str_slice.fits') | |
fits.PrimaryHDU(data=a[::2, ::2]).writeto(afits) | |
fits.PrimaryHDU(data=b[::2, ::2]).writeto(bfits) | |
> np.testing.assert_array_equal(fits.getdata(afits), a[::2, ::2]) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:201: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/convenience.py:204: in getdata | |
hdulist.close(closed=closed) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ TestImageFunctions.test_io_manipulation ____________________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x000000000dd141e0> | |
@pytest.mark.filterwarnings("ignore:Assigning the 'data' attribute is an " | |
"inherently unsafe operation") | |
def test_io_manipulation(self): | |
# Get a keyword value. An extension can be referred by name or by | |
# number. Both extension and keyword names are case insensitive. | |
with fits.open(self.data('test0.fits')) as r: | |
assert r['primary'].header['naxis'] == 0 | |
assert r[0].header['naxis'] == 0 | |
# If there are more than one extension with the same EXTNAME value, | |
# the EXTVER can be used (as the second argument) to distinguish | |
# the extension. | |
assert r['sci', 1].header['detector'] == 1 | |
# append (using "update()") a new card | |
r[0].header['xxx'] = 1.234e56 | |
assert ('\n'.join(str(x) for x in r[0].header.cards[-3:]) == | |
"EXPFLAG = 'NORMAL ' / Exposure interruption indicator \n" | |
"FILENAME= 'vtest3.fits' / File name \n" | |
"XXX = 1.234E+56 ") | |
# rename a keyword | |
r[0].header.rename_keyword('filename', 'fname') | |
pytest.raises(ValueError, r[0].header.rename_keyword, 'fname', | |
'history') | |
pytest.raises(ValueError, r[0].header.rename_keyword, 'fname', | |
'simple') | |
r[0].header.rename_keyword('fname', 'filename') | |
# get a subsection of data | |
assert np.array_equal(r[2].data[:3, :3], | |
np.array([[349, 349, 348], | |
[349, 349, 347], | |
[347, 350, 349]], dtype=np.int16)) | |
# We can create a new FITS file by opening a new file with "append" | |
# mode. | |
with fits.open(self.temp('test_new.fits'), mode='append') as n: | |
# Append the primary header and the 2nd extension to the new | |
# file. | |
n.append(r[0]) | |
n.append(r[2]) | |
# The flush method will write the current HDUList object back | |
# to the newly created file on disk. The HDUList is still open | |
# and can be further operated. | |
n.flush() | |
assert n[1].data[1, 1] == 349 | |
# modify a data point | |
> n[1].data[1, 1] = 99 | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:297: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000000dceb6a8>, <astropy.io.fits.hdu.image.ImageHDU object at 0x000000000dd56ec8>] | |
type = None, value = None, traceback = None | |
def __exit__(self, type, value, traceback): | |
> self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000000dceb6a8>, <astropy.io.fits.hdu.image.ImageHDU object at 0x000000000dd56ec8>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
self.flush(output_verify=output_verify, verbose=verbose) | |
finally: | |
if self._file and closed and hasattr(self._file, 'close'): | |
self._file.close() | |
# Give individual HDUs an opportunity to do on-close cleanup | |
for hdu in self: | |
> hdu._close(closed=closed) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:970: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.hdu.image.ImageHDU object at 0x000000000dd56ec8> | |
closed = True | |
def _close(self, closed=True): | |
# If the data was mmap'd, close the underlying mmap (this will | |
# prevent any future access to the .data attribute if there are | |
# not other references to it; if there are other references then | |
# it is up to the user to clean those up | |
if (closed and self._data_loaded and | |
_get_array_mmap(self.data) is not None): | |
> del self.data | |
pypy/site-packages/astropy/io/fits/hdu/base.py:748: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.utils.decorators.lazyproperty object at 0x00007f587adbe7a0> | |
obj = <astropy.io.fits.hdu.image.ImageHDU object at 0x000000000dd56ec8> | |
def __delete__(self, obj): | |
if self.fdel: | |
> self.fdel(obj) | |
pypy/site-packages/astropy/utils/decorators.py:765: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.hdu.image.ImageHDU object at 0x000000000dd56ec8> | |
def data(self): | |
# The deleter | |
if self._file is not None and self._data_loaded: | |
> data_refcount = sys.getrefcount(self.data) | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/hdu/base.py:117: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x000000000dd141e0> | |
@pytest.mark.filterwarnings("ignore:Assigning the 'data' attribute is an " | |
"inherently unsafe operation") | |
def test_io_manipulation(self): | |
# Get a keyword value. An extension can be referred by name or by | |
# number. Both extension and keyword names are case insensitive. | |
with fits.open(self.data('test0.fits')) as r: | |
assert r['primary'].header['naxis'] == 0 | |
assert r[0].header['naxis'] == 0 | |
# If there are more than one extension with the same EXTNAME value, | |
# the EXTVER can be used (as the second argument) to distinguish | |
# the extension. | |
assert r['sci', 1].header['detector'] == 1 | |
# append (using "update()") a new card | |
r[0].header['xxx'] = 1.234e56 | |
assert ('\n'.join(str(x) for x in r[0].header.cards[-3:]) == | |
"EXPFLAG = 'NORMAL ' / Exposure interruption indicator \n" | |
"FILENAME= 'vtest3.fits' / File name \n" | |
"XXX = 1.234E+56 ") | |
# rename a keyword | |
r[0].header.rename_keyword('filename', 'fname') | |
pytest.raises(ValueError, r[0].header.rename_keyword, 'fname', | |
'history') | |
pytest.raises(ValueError, r[0].header.rename_keyword, 'fname', | |
'simple') | |
r[0].header.rename_keyword('fname', 'filename') | |
# get a subsection of data | |
assert np.array_equal(r[2].data[:3, :3], | |
np.array([[349, 349, 348], | |
[349, 349, 347], | |
[347, 350, 349]], dtype=np.int16)) | |
# We can create a new FITS file by opening a new file with "append" | |
# mode. | |
with fits.open(self.temp('test_new.fits'), mode='append') as n: | |
# Append the primary header and the 2nd extension to the new | |
# file. | |
n.append(r[0]) | |
n.append(r[2]) | |
# The flush method will write the current HDUList object back | |
# to the newly created file on disk. The HDUList is still open | |
# and can be further operated. | |
n.flush() | |
assert n[1].data[1, 1] == 349 | |
# modify a data point | |
n[1].data[1, 1] = 99 | |
# When the file is closed, the most recent additions of | |
# extension(s) since last flush() will be appended, but any HDU | |
# already existed at the last flush will not be modified | |
del n | |
# If an existing file is opened with "append" mode, like the | |
# readonly mode, the HDU's will be read into the HDUList which can | |
# be modified in memory but can not be written back to the original | |
# file. A file opened with append mode can only add new HDU's. | |
os.rename(self.temp('test_new.fits'), | |
self.temp('test_append.fits')) | |
with fits.open(self.temp('test_append.fits'), mode='append') as a: | |
# The above change did not take effect since this was made | |
# after the flush(). | |
assert a[1].data[1, 1] == 349 | |
a.append(r[1]) | |
del a | |
# When changes are made to an HDUList which was opened with | |
# "update" mode, they will be written back to the original file | |
# when a flush/close is called. | |
os.rename(self.temp('test_append.fits'), | |
self.temp('test_update.fits')) | |
with fits.open(self.temp('test_update.fits'), mode='update') as u: | |
# When the changes do not alter the size structures of the | |
# original (or since last flush) HDUList, the changes are | |
# written back "in place". | |
assert u[0].header['rootname'] == 'U2EQ0201T' | |
u[0].header['rootname'] = 'abc' | |
assert u[1].data[1, 1] == 349 | |
u[1].data[1, 1] = 99 | |
u.flush() | |
# If the changes affect the size structure, e.g. adding or | |
# deleting HDU(s), header was expanded or reduced beyond | |
# existing number of blocks (2880 bytes in each block), or | |
# change the data size, the HDUList is written to a temporary | |
# file, the original file is deleted, and the temporary file is | |
# renamed to the original file name and reopened in the update | |
# mode. To a user, these two kinds of updating writeback seem | |
# to be the same, unless the optional argument in flush or | |
# close is set to 1. | |
del u[2] | |
u.flush() | |
# The write method in HDUList class writes the current HDUList, | |
# with all changes made up to now, to a new file. This method | |
# works the same disregard the mode the HDUList was opened | |
# with. | |
u.append(r[3]) | |
u.writeto(self.temp('test_new.fits')) | |
> del u | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:354: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________________ TestImageFunctions.test_section ________________________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x000000000cc66368> | |
def test_section(self): | |
# section testing | |
fs = fits.open(self.data('arange.fits')) | |
assert np.array_equal(fs[0].section[3, 2, 5], 357) | |
assert np.array_equal( | |
fs[0].section[3, 2, :], | |
np.array([352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362])) | |
assert np.array_equal(fs[0].section[3, 2, 4:], | |
np.array([356, 357, 358, 359, 360, 361, 362])) | |
assert np.array_equal(fs[0].section[3, 2, :8], | |
np.array([352, 353, 354, 355, 356, 357, 358, 359])) | |
assert np.array_equal(fs[0].section[3, 2, -8:8], | |
np.array([355, 356, 357, 358, 359])) | |
assert np.array_equal( | |
fs[0].section[3, 2:5, :], | |
np.array([[352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362], | |
[363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373], | |
[374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384]])) | |
assert np.array_equal(fs[0].section[3, :, :][:3, :3], | |
np.array([[330, 331, 332], | |
[341, 342, 343], | |
[352, 353, 354]])) | |
dat = fs[0].data | |
assert np.array_equal(fs[0].section[3, 2:5, :8], dat[3, 2:5, :8]) | |
assert np.array_equal(fs[0].section[3, 2:5, 3], dat[3, 2:5, 3]) | |
assert np.array_equal(fs[0].section[3:6, :, :][:3, :3, :3], | |
np.array([[[330, 331, 332], | |
[341, 342, 343], | |
[352, 353, 354]], | |
[[440, 441, 442], | |
[451, 452, 453], | |
[462, 463, 464]], | |
[[550, 551, 552], | |
[561, 562, 563], | |
[572, 573, 574]]])) | |
assert np.array_equal(fs[0].section[:, :, :][:3, :2, :2], | |
np.array([[[0, 1], | |
[11, 12]], | |
[[110, 111], | |
[121, 122]], | |
[[220, 221], | |
[231, 232]]])) | |
assert np.array_equal(fs[0].section[:, 2, :], dat[:, 2, :]) | |
assert np.array_equal(fs[0].section[:, 2:5, :], dat[:, 2:5, :]) | |
assert np.array_equal(fs[0].section[3:6, 3, :], dat[3:6, 3, :]) | |
assert np.array_equal(fs[0].section[3:6, 3:7, :], dat[3:6, 3:7, :]) | |
assert np.array_equal(fs[0].section[:, ::2], dat[:, ::2]) | |
assert np.array_equal(fs[0].section[:, [1, 2, 4], 3], | |
dat[:, [1, 2, 4], 3]) | |
bool_index = np.array([True, False, True, True, False, | |
False, True, True, False, True]) | |
assert np.array_equal(fs[0].section[:, bool_index, :], | |
dat[:, bool_index, :]) | |
assert np.array_equal( | |
fs[0].section[3:6, 3, :, ...], dat[3:6, 3, :, ...]) | |
assert np.array_equal(fs[0].section[..., ::2], dat[..., ::2]) | |
assert np.array_equal(fs[0].section[..., [1, 2, 4], 3], | |
dat[..., [1, 2, 4], 3]) | |
> fs.close() | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:472: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________ TestImageFunctions.test_section_data_single __________________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x000000001b013050> | |
def test_section_data_single(self): | |
a = np.array([1]) | |
hdu = fits.PrimaryHDU(a) | |
hdu.writeto(self.temp('test_new.fits')) | |
hdul = fits.open(self.temp('test_new.fits')) | |
sec = hdul[0].section | |
dat = hdul[0].data | |
assert np.array_equal(sec[0], dat[0]) | |
assert np.array_equal(sec[...], dat[...]) | |
assert np.array_equal(sec[..., 0], dat[..., 0]) | |
assert np.array_equal(sec[0, ...], dat[0, ...]) | |
> hdul.close() | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:486: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________ TestImageFunctions.test_section_data_square __________________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x00000000201f1788> | |
def test_section_data_square(self): | |
a = np.arange(4).reshape(2, 2) | |
hdu = fits.PrimaryHDU(a) | |
hdu.writeto(self.temp('test_new.fits')) | |
hdul = fits.open(self.temp('test_new.fits')) | |
d = hdul[0] | |
dat = hdul[0].data | |
assert (d.section[:, :] == dat[:, :]).all() | |
assert (d.section[0, :] == dat[0, :]).all() | |
assert (d.section[1, :] == dat[1, :]).all() | |
assert (d.section[:, 0] == dat[:, 0]).all() | |
assert (d.section[:, 1] == dat[:, 1]).all() | |
assert (d.section[0, 0] == dat[0, 0]).all() | |
assert (d.section[0, 1] == dat[0, 1]).all() | |
assert (d.section[1, 0] == dat[1, 0]).all() | |
assert (d.section[1, 1] == dat[1, 1]).all() | |
assert (d.section[0:1, 0:1] == dat[0:1, 0:1]).all() | |
assert (d.section[0:2, 0:1] == dat[0:2, 0:1]).all() | |
assert (d.section[0:1, 0:2] == dat[0:1, 0:2]).all() | |
assert (d.section[0:2, 0:2] == dat[0:2, 0:2]).all() | |
> hdul.close() | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:509: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________________ TestImageFunctions.test_section_data_cube ___________________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x000000001ab0d6a8> | |
def test_section_data_cube(self): | |
a = np.arange(18).reshape(2, 3, 3) | |
hdu = fits.PrimaryHDU(a) | |
hdu.writeto(self.temp('test_new.fits')) | |
hdul = fits.open(self.temp('test_new.fits')) | |
d = hdul[0] | |
dat = hdul[0].data | |
assert (d.section[:] == dat[:]).all() | |
assert (d.section[:, :] == dat[:, :]).all() | |
# Test that various combinations of indexing on the section are equal to | |
# indexing the data. | |
# Testing all combinations of scalar-index and [:] for each dimension. | |
for idx1 in [slice(None), 0, 1]: | |
for idx2 in [slice(None), 0, 1, 2]: | |
for idx3 in [slice(None), 0, 1, 2]: | |
nd_idx = (idx1, idx2, idx3) | |
assert (d.section[nd_idx] == dat[nd_idx]).all() | |
# Test all ways to slice the last dimension but keeping the first two. | |
for idx3 in [slice(0, 1), slice(0, 2), slice(0, 3), | |
slice(1, 2), slice(1, 3), slice(2, 3)]: | |
nd_idx = (slice(None), slice(None), idx3) | |
assert (d.section[nd_idx] == dat[nd_idx]).all() | |
# Test various combinations (not exhaustive) to slice all dimensions. | |
for idx1 in [slice(0, 1), slice(1, 2)]: | |
for idx2 in [slice(0, 1), slice(0, 2), slice(0, 3), | |
slice(1, 2), slice(1, 3)]: | |
for idx3 in [slice(0, 1), slice(0, 2), slice(0, 3), | |
slice(1, 2), slice(1, 3), slice(2, 3)]: | |
nd_idx = (idx1, idx2, idx3) | |
assert (d.section[nd_idx] == dat[nd_idx]).all() | |
> hdul.close() | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:547: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________________ TestImageFunctions.test_section_data_four ___________________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x00000000117b5bb0> | |
def test_section_data_four(self): | |
a = np.arange(256).reshape(4, 4, 4, 4) | |
hdu = fits.PrimaryHDU(a) | |
hdu.writeto(self.temp('test_new.fits')) | |
hdul = fits.open(self.temp('test_new.fits')) | |
d = hdul[0] | |
dat = hdul[0].data | |
assert (d.section[:, :, :, :] == dat[:, :, :, :]).all() | |
assert (d.section[:, :, :] == dat[:, :, :]).all() | |
assert (d.section[:, :] == dat[:, :]).all() | |
assert (d.section[:] == dat[:]).all() | |
assert (d.section[0, :, :, :] == dat[0, :, :, :]).all() | |
assert (d.section[0, :, 0, :] == dat[0, :, 0, :]).all() | |
assert (d.section[:, :, 0, :] == dat[:, :, 0, :]).all() | |
assert (d.section[:, 1, 0, :] == dat[:, 1, 0, :]).all() | |
assert (d.section[:, :, :, 1] == dat[:, :, :, 1]).all() | |
> hdul.close() | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:566: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________ TestImageFunctions.test_section_data_scaled __________________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x00000000141d8138> | |
def test_section_data_scaled(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/143 | |
This is like test_section_data_square but uses a file containing scaled | |
image data, to test that sections can work correctly with scaled data. | |
""" | |
hdul = fits.open(self.data('scale.fits')) | |
d = hdul[0] | |
dat = hdul[0].data | |
assert (d.section[:, :] == dat[:, :]).all() | |
assert (d.section[0, :] == dat[0, :]).all() | |
assert (d.section[1, :] == dat[1, :]).all() | |
assert (d.section[:, 0] == dat[:, 0]).all() | |
assert (d.section[:, 1] == dat[:, 1]).all() | |
assert (d.section[0, 0] == dat[0, 0]).all() | |
assert (d.section[0, 1] == dat[0, 1]).all() | |
assert (d.section[1, 0] == dat[1, 0]).all() | |
assert (d.section[1, 1] == dat[1, 1]).all() | |
assert (d.section[0:1, 0:1] == dat[0:1, 0:1]).all() | |
assert (d.section[0:2, 0:1] == dat[0:2, 0:1]).all() | |
assert (d.section[0:1, 0:2] == dat[0:1, 0:2]).all() | |
assert (d.section[0:2, 0:2] == dat[0:2, 0:2]).all() | |
> hdul.close() | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:592: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________ TestImageFunctions.test_do_not_scale_image_data ________________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x0000000018406870> | |
def test_do_not_scale_image_data(self): | |
with fits.open(self.data('scale.fits'), do_not_scale_image_data=True) as hdul: | |
> assert hdul[0].data.dtype == np.dtype('>i2') | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:615: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ TestImageFunctions.test_append_uint_data ___________________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x00000000133ec838> | |
def test_append_uint_data(self): | |
"""Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/56 | |
(BZERO and BSCALE added in the wrong location when appending scaled | |
data) | |
""" | |
fits.writeto(self.temp('test_new.fits'), data=np.array([], | |
dtype='uint8')) | |
d = np.zeros([100, 100]).astype('uint16') | |
fits.append(self.temp('test_new.fits'), data=d) | |
with fits.open(self.temp('test_new.fits'), uint=True) as f: | |
> assert f[1].data.dtype == 'uint16' | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:632: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________ TestImageFunctions.test_uint_header_consistency ________________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x0000000022856758> | |
def test_uint_header_consistency(self): | |
""" | |
Regression test for https://github.com/astropy/astropy/issues/2305 | |
This ensures that an HDU containing unsigned integer data always has | |
the apppriate BZERO value in its header. | |
""" | |
for int_size in (16, 32, 64): | |
# Just make an array of some unsigned ints that wouldn't fit in a | |
# signed int array of the same bit width | |
max_uint = (2 ** int_size) - 1 | |
if int_size == 64: | |
max_uint = np.uint64(int_size) | |
dtype = f'uint{int_size}' | |
arr = np.empty(100, dtype=dtype) | |
arr.fill(max_uint) | |
arr -= np.arange(100, dtype=dtype) | |
uint_hdu = fits.PrimaryHDU(data=arr) | |
assert np.all(uint_hdu.data == arr) | |
assert uint_hdu.data.dtype.name == f'uint{int_size}' | |
assert 'BZERO' in uint_hdu.header | |
assert uint_hdu.header['BZERO'] == (2 ** (int_size - 1)) | |
filename = f'uint{int_size}.fits' | |
uint_hdu.writeto(self.temp(filename)) | |
with fits.open(self.temp(filename), uint=True) as hdul: | |
new_uint_hdu = hdul[0] | |
assert np.all(new_uint_hdu.data == arr) | |
assert new_uint_hdu.data.dtype.name == f'uint{int_size}' | |
assert 'BZERO' in new_uint_hdu.header | |
> assert new_uint_hdu.header['BZERO'] == (2 ** (int_size - 1)) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:677: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_ TestImageFunctions.test_uint_header_keywords_removed_after_bitpix_change[False-False] _ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x00000000194b20c8> | |
from_file = False, do_not_scale = False | |
@pytest.mark.parametrize(('from_file'), (False, True)) | |
@pytest.mark.parametrize(('do_not_scale'), (False,)) | |
def test_uint_header_keywords_removed_after_bitpix_change(self, | |
from_file, | |
do_not_scale): | |
""" | |
Regression test for https://github.com/astropy/astropy/issues/4974 | |
BZERO/BSCALE should be removed if data is converted to a floating | |
point type. | |
Currently excluding the case where do_not_scale_image_data=True | |
because it is not clear what the expectation should be. | |
""" | |
arr = np.zeros(100, dtype='uint16') | |
if from_file: | |
# To generate the proper input file we always want to scale the | |
# data before writing it...otherwise when we open it will be | |
# regular (signed) int data. | |
tmp_uint = fits.PrimaryHDU(arr) | |
filename = 'unsigned_int.fits' | |
tmp_uint.writeto(self.temp(filename)) | |
with fits.open(self.temp(filename), | |
do_not_scale_image_data=do_not_scale) as f: | |
uint_hdu = f[0] | |
# Force a read before we close. | |
_ = uint_hdu.data | |
else: | |
uint_hdu = fits.PrimaryHDU(arr, | |
do_not_scale_image_data=do_not_scale) | |
# Make sure appropriate keywords are in the header. See | |
# https://github.com/astropy/astropy/pull/3916#issuecomment-122414532 | |
# for discussion. | |
assert 'BSCALE' in uint_hdu.header | |
assert 'BZERO' in uint_hdu.header | |
assert uint_hdu.header['BSCALE'] == 1 | |
assert uint_hdu.header['BZERO'] == 32768 | |
# Convert data to floating point... | |
uint_hdu.data = uint_hdu.data * 1.0 | |
# ...bitpix should be negative. | |
assert uint_hdu.header['BITPIX'] < 0 | |
# BSCALE and BZERO should NOT be in header any more. | |
assert 'BSCALE' not in uint_hdu.header | |
assert 'BZERO' not in uint_hdu.header | |
# This is the main test...the data values should round trip | |
# as zero. | |
filename = 'test_uint_to_float.fits' | |
uint_hdu.writeto(self.temp(filename)) | |
with fits.open(self.temp(filename)) as hdul: | |
> assert (hdul[0].data == 0).all() | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:735: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_ TestImageFunctions.test_uint_header_keywords_removed_after_bitpix_change[False-True] _ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x0000000016d3c4f0> | |
from_file = True, do_not_scale = False | |
@pytest.mark.parametrize(('from_file'), (False, True)) | |
@pytest.mark.parametrize(('do_not_scale'), (False,)) | |
def test_uint_header_keywords_removed_after_bitpix_change(self, | |
from_file, | |
do_not_scale): | |
""" | |
Regression test for https://github.com/astropy/astropy/issues/4974 | |
BZERO/BSCALE should be removed if data is converted to a floating | |
point type. | |
Currently excluding the case where do_not_scale_image_data=True | |
because it is not clear what the expectation should be. | |
""" | |
arr = np.zeros(100, dtype='uint16') | |
if from_file: | |
# To generate the proper input file we always want to scale the | |
# data before writing it...otherwise when we open it will be | |
# regular (signed) int data. | |
tmp_uint = fits.PrimaryHDU(arr) | |
filename = 'unsigned_int.fits' | |
tmp_uint.writeto(self.temp(filename)) | |
with fits.open(self.temp(filename), | |
do_not_scale_image_data=do_not_scale) as f: | |
uint_hdu = f[0] | |
# Force a read before we close. | |
> _ = uint_hdu.data | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:707: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________________ TestImageFunctions.test_blanks ________________________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x000000001b1e30f8> | |
def test_blanks(self): | |
"""Test image data with blank spots in it (which should show up as | |
NaNs in the data array. | |
""" | |
arr = np.zeros((10, 10), dtype=np.int32) | |
# One row will be blanks | |
arr[1] = 999 | |
hdu = fits.ImageHDU(data=arr) | |
hdu.header['BLANK'] = 999 | |
hdu.writeto(self.temp('test_new.fits')) | |
with fits.open(self.temp('test_new.fits')) as hdul: | |
> assert np.isnan(hdul[1].data[1]).all() | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:750: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________________ TestImageFunctions.test_invalid_blanks ____________________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x0000000020f43de0> | |
def test_invalid_blanks(self): | |
""" | |
Test that invalid use of the BLANK keyword leads to an appropriate | |
warning, and that the BLANK keyword is ignored when returning the | |
HDU data. | |
Regression test for https://github.com/astropy/astropy/issues/3865 | |
""" | |
arr = np.arange(5, dtype=np.float64) | |
hdu = fits.PrimaryHDU(data=arr) | |
hdu.header['BLANK'] = 2 | |
with catch_warnings() as w: | |
hdu.writeto(self.temp('test_new.fits')) | |
# Allow the HDU to be written, but there should be a warning | |
# when writing a header with BLANK when then data is not | |
# int | |
assert len(w) == 1 | |
assert "Invalid 'BLANK' keyword in header" in str(w[0].message) | |
# Should also get a warning when opening the file, and the BLANK | |
# value should not be applied | |
with catch_warnings() as w: | |
with fits.open(self.temp('test_new.fits')) as h: | |
assert len(w) == 1 | |
assert "Invalid 'BLANK' keyword in header" in str(w[0].message) | |
> assert np.all(arr == h[0].data) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:779: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________ TestImageFunctions.test_scale_back_with_blanks ________________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x000000001f334678> | |
def test_scale_back_with_blanks(self): | |
""" | |
Test that when auto-rescaling integer data with "blank" values (where | |
the blanks are replaced by NaN in the float data), that the "BLANK" | |
keyword is removed from the header. | |
Further, test that when using the ``scale_back=True`` option the blank | |
values are restored properly. | |
Regression test for https://github.com/astropy/astropy/issues/3865 | |
""" | |
# Make the sample file | |
arr = np.arange(5, dtype=np.int32) | |
hdu = fits.PrimaryHDU(data=arr) | |
hdu.scale('int16', bscale=1.23) | |
# Creating data that uses BLANK is currently kludgy--a separate issue | |
# TODO: Rewrite this test when scaling with blank support is better | |
# supported | |
# Let's just add a value to the data that should be converted to NaN | |
# when it is read back in: | |
filename = self.temp('test.fits') | |
hdu.data[0] = 9999 | |
hdu.header['BLANK'] = 9999 | |
hdu.writeto(filename) | |
with fits.open(filename) as hdul: | |
data = hdul[0].data | |
assert np.isnan(data[0]) | |
with pytest.warns(fits.verify.VerifyWarning, | |
match=r"Invalid 'BLANK' keyword in header"): | |
> hdul.writeto(self.temp('test2.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:814: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________________ TestImageFunctions.test_bzero_with_floats ___________________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x0000000006a04bf0> | |
def test_bzero_with_floats(self): | |
"""Test use of the BZERO keyword in an image HDU containing float | |
data. | |
""" | |
arr = np.zeros((10, 10)) - 1 | |
hdu = fits.ImageHDU(data=arr) | |
hdu.header['BZERO'] = 1.0 | |
hdu.writeto(self.temp('test_new.fits')) | |
with fits.open(self.temp('test_new.fits')) as hdul: | |
arr += 1 | |
> assert (hdul[1].data == arr).all() | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:849: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________ TestImageFunctions.test_rewriting_large_scaled_image _____________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x000000000f9c29f8> | |
def test_rewriting_large_scaled_image(self): | |
"""Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/84 and | |
https://aeon.stsci.edu/ssb/trac/pyfits/ticket/101 | |
""" | |
hdul = fits.open(self.data('fixed-1890.fits')) | |
orig_data = hdul[0].data | |
with ignore_warnings(): | |
hdul.writeto(self.temp('test_new.fits'), overwrite=True) | |
> hdul.close() | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:860: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________ TestImageFunctions.test_image_update_header __________________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x0000000012455f30> | |
def test_image_update_header(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/105 | |
Replacing the original header to an image HDU and saving should update | |
the NAXISn keywords appropriately and save the image data correctly. | |
""" | |
# Copy the original file before saving to it | |
self.copy_file('test0.fits') | |
with fits.open(self.temp('test0.fits'), mode='update') as hdul: | |
orig_data = hdul[1].data.copy() | |
hdr_copy = hdul[1].header.copy() | |
del hdr_copy['NAXIS*'] | |
> hdul[1].header = hdr_copy | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:906: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________ TestImageFunctions.test_open_scaled_in_update_mode ______________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x00000000116b4b48> | |
def test_open_scaled_in_update_mode(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/119 | |
(Don't update scaled image data if the data is not read) | |
This ensures that merely opening and closing a file containing scaled | |
image data does not cause any change to the data (or the header). | |
Changes should only occur if the data is accessed. | |
""" | |
# Copy the original file before making any possible changes to it | |
self.copy_file('scale.fits') | |
mtime = os.stat(self.temp('scale.fits')).st_mtime | |
time.sleep(1) | |
fits.open(self.temp('scale.fits'), mode='update').close() | |
# Ensure that no changes were made to the file merely by immediately | |
# opening and closing it. | |
assert mtime == os.stat(self.temp('scale.fits')).st_mtime | |
# Insert a slight delay to ensure the mtime does change when the file | |
# is changed | |
time.sleep(1) | |
hdul = fits.open(self.temp('scale.fits'), 'update') | |
orig_data = hdul[0].data | |
> hdul.close() | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:939: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________________ TestImageFunctions.test_scale_back ______________________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x00000000113293d0> | |
def test_scale_back(self): | |
"""A simple test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/120 | |
The scale_back feature for image HDUs. | |
""" | |
self.copy_file('scale.fits') | |
with fits.open(self.temp('scale.fits'), mode='update', | |
scale_back=True) as hdul: | |
orig_bitpix = hdul[0].header['BITPIX'] | |
orig_bzero = hdul[0].header['BZERO'] | |
orig_bscale = hdul[0].header['BSCALE'] | |
orig_data = hdul[0].data.copy() | |
> hdul[0].data[0] = 0 | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:976: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________________ TestImageFunctions.test_image_none ______________________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x0000000022367d38> | |
def test_image_none(self): | |
""" | |
Regression test for https://github.com/spacetelescope/PyFITS/issues/27 | |
""" | |
with fits.open(self.data('test0.fits')) as h: | |
h[1].data | |
h[1].data = None | |
> h[1].writeto(self.temp('test.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:998: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________________ TestImageFunctions.test_invalid_blank _____________________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x0000000016c698d8> | |
def test_invalid_blank(self): | |
""" | |
Regression test for https://github.com/astropy/astropy/issues/2711 | |
If the BLANK keyword contains an invalid value it should be ignored for | |
any calculations (though a warning should be issued). | |
""" | |
data = np.arange(100, dtype=np.float64) | |
hdu = fits.PrimaryHDU(data) | |
hdu.header['BLANK'] = 'nan' | |
with pytest.warns(fits.verify.VerifyWarning, match=r"Invalid value for " | |
r"'BLANK' keyword in header: 'nan'"): | |
hdu.writeto(self.temp('test.fits')) | |
with catch_warnings() as w: | |
with fits.open(self.temp('test.fits')) as hdul: | |
> assert np.all(hdul[0].data == data) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1023: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________ TestImageFunctions.test_scale_back_uint_assignment ______________ | |
self = <astropy.io.fits.tests.test_image.TestImageFunctions object at 0x00000000149d40c8> | |
def test_scale_back_uint_assignment(self): | |
""" | |
Extend fix for #4600 to assignment to data | |
Suggested by: | |
https://github.com/astropy/astropy/pull/4602#issuecomment-208713748 | |
""" | |
a = np.arange(100, 200, dtype=np.uint16) | |
fits.PrimaryHDU(a).writeto(self.temp('test.fits')) | |
with fits.open(self.temp('test.fits'), mode="update", | |
scale_back=True) as (hdu,): | |
hdu.data[:] = 0 | |
> assert np.allclose(hdu.data, 0) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1086: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________________ TestCompressedImage.test_empty ________________________ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000011299168>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x0000000011299088>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
> self.flush(output_verify=output_verify, verbose=verbose) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:963: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
args = ([<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000011299168>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x0000000011299088>],) | |
kwargs = {'output_verify': 'exception', 'verbose': False} | |
curr_thread = <_MainThread(MainThread, started 140018066300352)> | |
single_thread = True | |
SigintHandler = <class 'astropy.io.fits.util.ignore_sigint.<locals>.wrapped.<locals>.SigintHandler'> | |
sigint_handler = <astropy.io.fits.util.ignore_sigint.<locals>.wrapped.<locals>.SigintHandler object at 0x00000000112848a8> | |
old_handler = <built-in function default_int_handler> | |
@wraps(func) | |
def wrapped(*args, **kwargs): | |
# Get the name of the current thread and determine if this is a single | |
# threaded application | |
curr_thread = threading.currentThread() | |
single_thread = (threading.activeCount() == 1 and | |
curr_thread.getName() == 'MainThread') | |
class SigintHandler: | |
def __init__(self): | |
self.sigint_received = False | |
def __call__(self, signum, frame): | |
warnings.warn('KeyboardInterrupt ignored until {} is ' | |
'complete!'.format(func.__name__), | |
AstropyUserWarning) | |
self.sigint_received = True | |
sigint_handler = SigintHandler() | |
# Define new signal interput handler | |
if single_thread: | |
# Install new handler | |
old_handler = signal.signal(signal.SIGINT, sigint_handler) | |
try: | |
> func(*args, **kwargs) | |
pypy/site-packages/astropy/io/fits/util.py:241: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000011299168>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x0000000011299088>] | |
output_verify = 'exception', verbose = False | |
@ignore_sigint | |
def flush(self, output_verify='fix', verbose=False): | |
""" | |
Force a write of the `HDUList` back to the file (for append and | |
update modes only). | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print verbose messages | |
""" | |
if self._file.mode not in ('append', 'update', 'ostream'): | |
warnings.warn("Flush for '{}' mode is not supported." | |
.format(self._file.mode), AstropyUserWarning) | |
return | |
if self._save_backup and self._file.mode in ('append', 'update'): | |
filename = self._file.name | |
if os.path.exists(filename): | |
# The the file doesn't actually exist anymore for some reason | |
# then there's no point in trying to make a backup | |
backup = filename + '.bak' | |
idx = 1 | |
while os.path.exists(backup): | |
backup = filename + '.bak.' + str(idx) | |
idx += 1 | |
warnings.warn('Saving a backup of {} to {}.'.format( | |
filename, backup), AstropyUserWarning) | |
try: | |
shutil.copy(filename, backup) | |
except OSError as exc: | |
raise OSError('Failed to save backup to destination {}: ' | |
'{}'.format(filename, exc)) | |
self.verify(option=output_verify) | |
if self._file.mode in ('append', 'ostream'): | |
for hdu in self: | |
if verbose: | |
try: | |
extver = str(hdu._header['extver']) | |
except KeyError: | |
extver = '' | |
# only append HDU's which are "new" | |
if hdu._new: | |
hdu._prewriteto(checksum=hdu._output_checksum) | |
with _free_space_check(self): | |
hdu._writeto(self._file) | |
if verbose: | |
print('append HDU', hdu.name, extver) | |
hdu._new = False | |
hdu._postwriteto() | |
elif self._file.mode == 'update': | |
> self._flush_update() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:842: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000011299168>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x0000000011299088>] | |
def _flush_update(self): | |
"""Implements flushing changes to a file in update mode.""" | |
for hdu in self: | |
# Need to all _prewriteto() for each HDU first to determine if | |
# resizing will be necessary | |
hdu._prewriteto(checksum=hdu._output_checksum, inplace=True) | |
try: | |
self._wasresized() | |
# if the HDUList is resized, need to write out the entire contents of | |
# the hdulist to the file. | |
if self._resize or self._file.compression: | |
> self._flush_resize() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:1258: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000011299168>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x0000000011299088>] | |
def _flush_resize(self): | |
""" | |
Implements flushing changes in update mode when parts of one or more HDU | |
need to be resized. | |
""" | |
old_name = self._file.name | |
old_memmap = self._file.memmap | |
name = _tmp_name(old_name) | |
if not self._file.file_like: | |
old_mode = os.stat(old_name).st_mode | |
# The underlying file is an actual file object. The HDUList is | |
# resized, so we need to write it to a tmp file, delete the | |
# original file, and rename the tmp file to the original file. | |
if self._file.compression == 'gzip': | |
new_file = gzip.GzipFile(name, mode='ab+') | |
elif self._file.compression == 'bzip2': | |
if not HAS_BZ2: | |
raise ModuleNotFoundError( | |
"This Python installation does not provide the bz2 module.") | |
new_file = bz2.BZ2File(name, mode='w') | |
else: | |
new_file = name | |
with self.fromfile(new_file, mode='append') as hdulist: | |
for hdu in self: | |
hdu._writeto(hdulist._file, inplace=True, copy=True) | |
if sys.platform.startswith('win'): | |
# Collect a list of open mmaps to the data; this well be | |
# used later. See below. | |
mmaps = [(idx, _get_array_mmap(hdu.data), hdu.data) | |
for idx, hdu in enumerate(self) if hdu._has_data] | |
hdulist._file.close() | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:1307: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x0000000011284020> | |
def test_empty(self): | |
""" | |
Regression test for https://github.com/astropy/astropy/issues/2595 | |
""" | |
hdu = fits.CompImageHDU() | |
assert hdu.data is None | |
hdu.writeto(self.temp('test.fits')) | |
with fits.open(self.temp('test.fits'), mode='update') as hdul: | |
assert len(hdul) == 2 | |
assert isinstance(hdul[1], fits.CompImageHDU) | |
assert hdul[1].data is None | |
# Now test replacing the empty data with an array and see what | |
# happens | |
> hdul[1].data = np.arange(100, dtype=np.int32) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1106: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________ TestCompressedImage.test_comp_image[<-data0-RICE_1-16] ____________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x000000001d978d08> | |
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., 0., 0., 0., 0., 0., 0., 0., 0.], | |
[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]], dtype=float32) | |
compression_type = 'RICE_1', quantize_level = 16, byte_order = '<' | |
@pytest.mark.parametrize( | |
('data', 'compression_type', 'quantize_level'), | |
[(np.zeros((2, 10, 10), dtype=np.float32), 'RICE_1', 16), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_1', -0.01), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_2', -0.01), | |
(np.zeros((100, 100)) + 1, 'HCOMPRESS_1', 16), | |
(np.zeros((10, 10)), 'PLIO_1', 16)]) | |
@pytest.mark.parametrize('byte_order', ['<', '>']) | |
def test_comp_image(self, data, compression_type, quantize_level, | |
byte_order): | |
data = data.newbyteorder(byte_order) | |
primary_hdu = fits.PrimaryHDU() | |
ofd = fits.HDUList(primary_hdu) | |
chdu = fits.CompImageHDU(data, name='SCI', | |
compression_type=compression_type, | |
quantize_level=quantize_level) | |
ofd.append(chdu) | |
ofd.writeto(self.temp('test_new.fits'), overwrite=True) | |
ofd.close() | |
with fits.open(self.temp('test_new.fits')) as fd: | |
assert (fd[1].data == data).all() | |
assert fd[1].header['NAXIS'] == chdu.header['NAXIS'] | |
assert fd[1].header['NAXIS1'] == chdu.header['NAXIS1'] | |
assert fd[1].header['NAXIS2'] == chdu.header['NAXIS2'] | |
> assert fd[1].header['BITPIX'] == chdu.header['BITPIX'] | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1137: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________ TestCompressedImage.test_comp_image[<-data1-GZIP_1--0.01] ___________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x00007f587a7874b0> | |
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., 0., 0., 0., 0., 0., 0., 0., 0.], | |
[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]], dtype=float32) | |
compression_type = 'GZIP_1', quantize_level = -0.01, byte_order = '<' | |
@pytest.mark.parametrize( | |
('data', 'compression_type', 'quantize_level'), | |
[(np.zeros((2, 10, 10), dtype=np.float32), 'RICE_1', 16), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_1', -0.01), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_2', -0.01), | |
(np.zeros((100, 100)) + 1, 'HCOMPRESS_1', 16), | |
(np.zeros((10, 10)), 'PLIO_1', 16)]) | |
@pytest.mark.parametrize('byte_order', ['<', '>']) | |
def test_comp_image(self, data, compression_type, quantize_level, | |
byte_order): | |
data = data.newbyteorder(byte_order) | |
primary_hdu = fits.PrimaryHDU() | |
ofd = fits.HDUList(primary_hdu) | |
chdu = fits.CompImageHDU(data, name='SCI', | |
compression_type=compression_type, | |
quantize_level=quantize_level) | |
ofd.append(chdu) | |
ofd.writeto(self.temp('test_new.fits'), overwrite=True) | |
ofd.close() | |
with fits.open(self.temp('test_new.fits')) as fd: | |
assert (fd[1].data == data).all() | |
assert fd[1].header['NAXIS'] == chdu.header['NAXIS'] | |
assert fd[1].header['NAXIS1'] == chdu.header['NAXIS1'] | |
assert fd[1].header['NAXIS2'] == chdu.header['NAXIS2'] | |
> assert fd[1].header['BITPIX'] == chdu.header['BITPIX'] | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1137: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________ TestCompressedImage.test_comp_image[<-data2-GZIP_2--0.01] ___________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x000000000ddf4bb8> | |
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., 0., 0., 0., 0., 0., 0., 0., 0.], | |
[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]], dtype=float32) | |
compression_type = 'GZIP_2', quantize_level = -0.01, byte_order = '<' | |
@pytest.mark.parametrize( | |
('data', 'compression_type', 'quantize_level'), | |
[(np.zeros((2, 10, 10), dtype=np.float32), 'RICE_1', 16), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_1', -0.01), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_2', -0.01), | |
(np.zeros((100, 100)) + 1, 'HCOMPRESS_1', 16), | |
(np.zeros((10, 10)), 'PLIO_1', 16)]) | |
@pytest.mark.parametrize('byte_order', ['<', '>']) | |
def test_comp_image(self, data, compression_type, quantize_level, | |
byte_order): | |
data = data.newbyteorder(byte_order) | |
primary_hdu = fits.PrimaryHDU() | |
ofd = fits.HDUList(primary_hdu) | |
chdu = fits.CompImageHDU(data, name='SCI', | |
compression_type=compression_type, | |
quantize_level=quantize_level) | |
ofd.append(chdu) | |
ofd.writeto(self.temp('test_new.fits'), overwrite=True) | |
ofd.close() | |
with fits.open(self.temp('test_new.fits')) as fd: | |
assert (fd[1].data == data).all() | |
assert fd[1].header['NAXIS'] == chdu.header['NAXIS'] | |
assert fd[1].header['NAXIS1'] == chdu.header['NAXIS1'] | |
assert fd[1].header['NAXIS2'] == chdu.header['NAXIS2'] | |
> assert fd[1].header['BITPIX'] == chdu.header['BITPIX'] | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1137: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________ TestCompressedImage.test_comp_image[<-data3-HCOMPRESS_1-16] __________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x000000000d20c1e0> | |
data = array([[1., 1., 1., ..., 1., 1., 1.], | |
[1., 1., 1., ..., 1., 1., 1.], | |
[1., 1., 1., ..., 1., 1., 1.], | |
..., | |
[1., 1., 1., ..., 1., 1., 1.], | |
[1., 1., 1., ..., 1., 1., 1.], | |
[1., 1., 1., ..., 1., 1., 1.]]) | |
compression_type = 'HCOMPRESS_1', quantize_level = 16, byte_order = '<' | |
@pytest.mark.parametrize( | |
('data', 'compression_type', 'quantize_level'), | |
[(np.zeros((2, 10, 10), dtype=np.float32), 'RICE_1', 16), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_1', -0.01), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_2', -0.01), | |
(np.zeros((100, 100)) + 1, 'HCOMPRESS_1', 16), | |
(np.zeros((10, 10)), 'PLIO_1', 16)]) | |
@pytest.mark.parametrize('byte_order', ['<', '>']) | |
def test_comp_image(self, data, compression_type, quantize_level, | |
byte_order): | |
data = data.newbyteorder(byte_order) | |
primary_hdu = fits.PrimaryHDU() | |
ofd = fits.HDUList(primary_hdu) | |
chdu = fits.CompImageHDU(data, name='SCI', | |
compression_type=compression_type, | |
quantize_level=quantize_level) | |
ofd.append(chdu) | |
ofd.writeto(self.temp('test_new.fits'), overwrite=True) | |
ofd.close() | |
with fits.open(self.temp('test_new.fits')) as fd: | |
assert (fd[1].data == data).all() | |
assert fd[1].header['NAXIS'] == chdu.header['NAXIS'] | |
assert fd[1].header['NAXIS1'] == chdu.header['NAXIS1'] | |
assert fd[1].header['NAXIS2'] == chdu.header['NAXIS2'] | |
> assert fd[1].header['BITPIX'] == chdu.header['BITPIX'] | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1137: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________ TestCompressedImage.test_comp_image[<-data4-PLIO_1-16] ____________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x0000000012a0d948> | |
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., 0., 0., 0.], | |
[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], | |
[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]) | |
compression_type = 'PLIO_1', quantize_level = 16, byte_order = '<' | |
@pytest.mark.parametrize( | |
('data', 'compression_type', 'quantize_level'), | |
[(np.zeros((2, 10, 10), dtype=np.float32), 'RICE_1', 16), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_1', -0.01), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_2', -0.01), | |
(np.zeros((100, 100)) + 1, 'HCOMPRESS_1', 16), | |
(np.zeros((10, 10)), 'PLIO_1', 16)]) | |
@pytest.mark.parametrize('byte_order', ['<', '>']) | |
def test_comp_image(self, data, compression_type, quantize_level, | |
byte_order): | |
data = data.newbyteorder(byte_order) | |
primary_hdu = fits.PrimaryHDU() | |
ofd = fits.HDUList(primary_hdu) | |
chdu = fits.CompImageHDU(data, name='SCI', | |
compression_type=compression_type, | |
quantize_level=quantize_level) | |
ofd.append(chdu) | |
ofd.writeto(self.temp('test_new.fits'), overwrite=True) | |
ofd.close() | |
with fits.open(self.temp('test_new.fits')) as fd: | |
assert (fd[1].data == data).all() | |
assert fd[1].header['NAXIS'] == chdu.header['NAXIS'] | |
assert fd[1].header['NAXIS1'] == chdu.header['NAXIS1'] | |
assert fd[1].header['NAXIS2'] == chdu.header['NAXIS2'] | |
> assert fd[1].header['BITPIX'] == chdu.header['BITPIX'] | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1137: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________ TestCompressedImage.test_comp_image[>-data0-RICE_1-16] ____________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x000000001a0e0f70> | |
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., 0., 0., 0., 0., 0., 0., 0., 0.], | |
[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]], dtype=float32) | |
compression_type = 'RICE_1', quantize_level = 16, byte_order = '>' | |
@pytest.mark.parametrize( | |
('data', 'compression_type', 'quantize_level'), | |
[(np.zeros((2, 10, 10), dtype=np.float32), 'RICE_1', 16), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_1', -0.01), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_2', -0.01), | |
(np.zeros((100, 100)) + 1, 'HCOMPRESS_1', 16), | |
(np.zeros((10, 10)), 'PLIO_1', 16)]) | |
@pytest.mark.parametrize('byte_order', ['<', '>']) | |
def test_comp_image(self, data, compression_type, quantize_level, | |
byte_order): | |
data = data.newbyteorder(byte_order) | |
primary_hdu = fits.PrimaryHDU() | |
ofd = fits.HDUList(primary_hdu) | |
chdu = fits.CompImageHDU(data, name='SCI', | |
compression_type=compression_type, | |
quantize_level=quantize_level) | |
ofd.append(chdu) | |
ofd.writeto(self.temp('test_new.fits'), overwrite=True) | |
ofd.close() | |
with fits.open(self.temp('test_new.fits')) as fd: | |
assert (fd[1].data == data).all() | |
assert fd[1].header['NAXIS'] == chdu.header['NAXIS'] | |
assert fd[1].header['NAXIS1'] == chdu.header['NAXIS1'] | |
assert fd[1].header['NAXIS2'] == chdu.header['NAXIS2'] | |
> assert fd[1].header['BITPIX'] == chdu.header['BITPIX'] | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1137: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________ TestCompressedImage.test_comp_image[>-data1-GZIP_1--0.01] ___________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x00000000114a5980> | |
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., 0., 0., 0., 0., 0., 0., 0., 0.], | |
[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]], dtype=float32) | |
compression_type = 'GZIP_1', quantize_level = -0.01, byte_order = '>' | |
@pytest.mark.parametrize( | |
('data', 'compression_type', 'quantize_level'), | |
[(np.zeros((2, 10, 10), dtype=np.float32), 'RICE_1', 16), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_1', -0.01), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_2', -0.01), | |
(np.zeros((100, 100)) + 1, 'HCOMPRESS_1', 16), | |
(np.zeros((10, 10)), 'PLIO_1', 16)]) | |
@pytest.mark.parametrize('byte_order', ['<', '>']) | |
def test_comp_image(self, data, compression_type, quantize_level, | |
byte_order): | |
data = data.newbyteorder(byte_order) | |
primary_hdu = fits.PrimaryHDU() | |
ofd = fits.HDUList(primary_hdu) | |
chdu = fits.CompImageHDU(data, name='SCI', | |
compression_type=compression_type, | |
quantize_level=quantize_level) | |
ofd.append(chdu) | |
ofd.writeto(self.temp('test_new.fits'), overwrite=True) | |
ofd.close() | |
with fits.open(self.temp('test_new.fits')) as fd: | |
assert (fd[1].data == data).all() | |
assert fd[1].header['NAXIS'] == chdu.header['NAXIS'] | |
assert fd[1].header['NAXIS1'] == chdu.header['NAXIS1'] | |
assert fd[1].header['NAXIS2'] == chdu.header['NAXIS2'] | |
> assert fd[1].header['BITPIX'] == chdu.header['BITPIX'] | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1137: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________ TestCompressedImage.test_comp_image[>-data2-GZIP_2--0.01] ___________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x0000000022361590> | |
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., 0., 0., 0., 0., 0., 0., 0., 0.], | |
[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]], dtype=float32) | |
compression_type = 'GZIP_2', quantize_level = -0.01, byte_order = '>' | |
@pytest.mark.parametrize( | |
('data', 'compression_type', 'quantize_level'), | |
[(np.zeros((2, 10, 10), dtype=np.float32), 'RICE_1', 16), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_1', -0.01), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_2', -0.01), | |
(np.zeros((100, 100)) + 1, 'HCOMPRESS_1', 16), | |
(np.zeros((10, 10)), 'PLIO_1', 16)]) | |
@pytest.mark.parametrize('byte_order', ['<', '>']) | |
def test_comp_image(self, data, compression_type, quantize_level, | |
byte_order): | |
data = data.newbyteorder(byte_order) | |
primary_hdu = fits.PrimaryHDU() | |
ofd = fits.HDUList(primary_hdu) | |
chdu = fits.CompImageHDU(data, name='SCI', | |
compression_type=compression_type, | |
quantize_level=quantize_level) | |
ofd.append(chdu) | |
ofd.writeto(self.temp('test_new.fits'), overwrite=True) | |
ofd.close() | |
with fits.open(self.temp('test_new.fits')) as fd: | |
assert (fd[1].data == data).all() | |
assert fd[1].header['NAXIS'] == chdu.header['NAXIS'] | |
assert fd[1].header['NAXIS1'] == chdu.header['NAXIS1'] | |
assert fd[1].header['NAXIS2'] == chdu.header['NAXIS2'] | |
> assert fd[1].header['BITPIX'] == chdu.header['BITPIX'] | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1137: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________ TestCompressedImage.test_comp_image[>-data3-HCOMPRESS_1-16] __________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x0000000019c86a30> | |
data = array([[3.03865e-319, 3.03865e-319, 3.03865e-319, ..., 3.03865e-319, | |
3.03865e-319, 3.03865e-319], | |
[3.03...03865e-319], | |
[3.03865e-319, 3.03865e-319, 3.03865e-319, ..., 3.03865e-319, | |
3.03865e-319, 3.03865e-319]]) | |
compression_type = 'HCOMPRESS_1', quantize_level = 16, byte_order = '>' | |
@pytest.mark.parametrize( | |
('data', 'compression_type', 'quantize_level'), | |
[(np.zeros((2, 10, 10), dtype=np.float32), 'RICE_1', 16), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_1', -0.01), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_2', -0.01), | |
(np.zeros((100, 100)) + 1, 'HCOMPRESS_1', 16), | |
(np.zeros((10, 10)), 'PLIO_1', 16)]) | |
@pytest.mark.parametrize('byte_order', ['<', '>']) | |
def test_comp_image(self, data, compression_type, quantize_level, | |
byte_order): | |
data = data.newbyteorder(byte_order) | |
primary_hdu = fits.PrimaryHDU() | |
ofd = fits.HDUList(primary_hdu) | |
chdu = fits.CompImageHDU(data, name='SCI', | |
compression_type=compression_type, | |
quantize_level=quantize_level) | |
ofd.append(chdu) | |
ofd.writeto(self.temp('test_new.fits'), overwrite=True) | |
ofd.close() | |
with fits.open(self.temp('test_new.fits')) as fd: | |
assert (fd[1].data == data).all() | |
assert fd[1].header['NAXIS'] == chdu.header['NAXIS'] | |
assert fd[1].header['NAXIS1'] == chdu.header['NAXIS1'] | |
assert fd[1].header['NAXIS2'] == chdu.header['NAXIS2'] | |
> assert fd[1].header['BITPIX'] == chdu.header['BITPIX'] | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1137: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________ TestCompressedImage.test_comp_image[>-data4-PLIO_1-16] ____________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x000000001647b210> | |
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., 0., 0., 0.], | |
[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], | |
[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]) | |
compression_type = 'PLIO_1', quantize_level = 16, byte_order = '>' | |
@pytest.mark.parametrize( | |
('data', 'compression_type', 'quantize_level'), | |
[(np.zeros((2, 10, 10), dtype=np.float32), 'RICE_1', 16), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_1', -0.01), | |
(np.zeros((2, 10, 10), dtype=np.float32), 'GZIP_2', -0.01), | |
(np.zeros((100, 100)) + 1, 'HCOMPRESS_1', 16), | |
(np.zeros((10, 10)), 'PLIO_1', 16)]) | |
@pytest.mark.parametrize('byte_order', ['<', '>']) | |
def test_comp_image(self, data, compression_type, quantize_level, | |
byte_order): | |
data = data.newbyteorder(byte_order) | |
primary_hdu = fits.PrimaryHDU() | |
ofd = fits.HDUList(primary_hdu) | |
chdu = fits.CompImageHDU(data, name='SCI', | |
compression_type=compression_type, | |
quantize_level=quantize_level) | |
ofd.append(chdu) | |
ofd.writeto(self.temp('test_new.fits'), overwrite=True) | |
ofd.close() | |
with fits.open(self.temp('test_new.fits')) as fd: | |
assert (fd[1].data == data).all() | |
assert fd[1].header['NAXIS'] == chdu.header['NAXIS'] | |
assert fd[1].header['NAXIS1'] == chdu.header['NAXIS1'] | |
assert fd[1].header['NAXIS2'] == chdu.header['NAXIS2'] | |
> assert fd[1].header['BITPIX'] == chdu.header['BITPIX'] | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1137: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________ TestCompressedImage.test_comp_image_hcompress_image_stack ___________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x000000001875d050> | |
def test_comp_image_hcompress_image_stack(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/171 | |
Tests that data containing more than two dimensions can be | |
compressed with HCOMPRESS_1 so long as the user-supplied tile size can | |
be flattened to two dimensions. | |
""" | |
cube = np.arange(300, dtype=np.float32).reshape(3, 10, 10) | |
hdu = fits.CompImageHDU(data=cube, name='SCI', | |
compression_type='HCOMPRESS_1', | |
quantize_level=16, tile_size=[5, 5, 1]) | |
hdu.writeto(self.temp('test.fits')) | |
with fits.open(self.temp('test.fits')) as hdul: | |
# HCOMPRESSed images are allowed to deviate from the original by | |
# about 1/quantize_level of the RMS in each tile. | |
> assert np.abs(hdul['SCI'].data - cube).max() < 1./15. | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1198: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________ TestCompressedImage.test_subtractive_dither_seed _______________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x0000000022a339f0> | |
def test_subtractive_dither_seed(self): | |
""" | |
Regression test for https://github.com/spacetelescope/PyFITS/issues/32 | |
Ensure that when floating point data is compressed with the | |
SUBTRACTIVE_DITHER_1 quantization method that the correct ZDITHER0 seed | |
is added to the header, and that the data can be correctly | |
decompressed. | |
""" | |
array = np.arange(100.0).reshape(10, 10) | |
csum = (array[0].view('uint8').sum() % 10000) + 1 | |
hdu = fits.CompImageHDU(data=array, | |
quantize_method=SUBTRACTIVE_DITHER_1, | |
dither_seed=DITHER_SEED_CHECKSUM) | |
hdu.writeto(self.temp('test.fits')) | |
with fits.open(self.temp('test.fits')) as hdul: | |
assert isinstance(hdul[1], fits.CompImageHDU) | |
assert 'ZQUANTIZ' in hdul[1]._header | |
assert hdul[1]._header['ZQUANTIZ'] == 'SUBTRACTIVE_DITHER_1' | |
assert 'ZDITHER0' in hdul[1]._header | |
assert hdul[1]._header['ZDITHER0'] == csum | |
> assert np.all(hdul[1].data == array) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1223: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________ TestCompressedImage.test_open_scaled_in_update_mode_compressed ________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x000000000e11ea68> | |
def test_open_scaled_in_update_mode_compressed(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/88 2 | |
Identical to test_open_scaled_in_update_mode() but with a compressed | |
version of the scaled image. | |
""" | |
# Copy+compress the original file before making any possible changes to | |
# it | |
with fits.open(self.data('scale.fits'), | |
do_not_scale_image_data=True) as hdul: | |
chdu = fits.CompImageHDU(data=hdul[0].data, | |
header=hdul[0].header) | |
> chdu.writeto(self.temp('scale.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1273: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________ TestCompressedImage.test_write_comp_hdu_direct_from_existing _________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x00000000054dea68> | |
def test_write_comp_hdu_direct_from_existing(self): | |
with fits.open(self.data('comp.fits')) as hdul: | |
> hdul[1].writeto(self.temp('test.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1315: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______ TestCompressedImage.test_rewriting_large_scaled_image_compressed _______ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x000000000c608e90> | |
def test_rewriting_large_scaled_image_compressed(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/88 1 | |
Identical to test_rewriting_large_scaled_image() but with a compressed | |
image. | |
""" | |
with fits.open(self.data('fixed-1890.fits'), | |
do_not_scale_image_data=True) as hdul: | |
chdu = fits.CompImageHDU(data=hdul[0].data, | |
header=hdul[0].header) | |
> chdu.writeto(self.temp('fixed-1890-z.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1335: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________ TestCompressedImage.test_scale_back_compressed ________________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x000000000d29e4b8> | |
def test_scale_back_compressed(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/88 3 | |
Identical to test_scale_back() but uses a compressed image. | |
""" | |
# Create a compressed version of the scaled image | |
with fits.open(self.data('scale.fits'), | |
do_not_scale_image_data=True) as hdul: | |
chdu = fits.CompImageHDU(data=hdul[0].data, | |
header=hdul[0].header) | |
> chdu.writeto(self.temp('scale.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1385: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________ TestCompressedImage.test_lossless_gzip_compression ______________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x000000000f3a58a0> | |
def test_lossless_gzip_compression(self): | |
"""Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/198""" | |
rng = np.random.RandomState(seed=42) | |
noise = rng.normal(size=(20, 20)) | |
chdu1 = fits.CompImageHDU(data=noise, compression_type='GZIP_1') | |
# First make a test image with lossy compression and make sure it | |
# wasn't compressed perfectly. This shouldn't happen ever, but just to | |
# make sure the test non-trivial. | |
chdu1.writeto(self.temp('test.fits')) | |
with fits.open(self.temp('test.fits')) as h: | |
> assert np.abs(noise - h[1].data).max() > 0.0 | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1427: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________ TestCompressedImage.test_compression_with_gzip_column _____________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x00000000164f50f8> | |
def test_compression_with_gzip_column(self): | |
""" | |
Regression test for https://github.com/spacetelescope/PyFITS/issues/71 | |
""" | |
arr = np.zeros((2, 7000), dtype='float32') | |
# The first row (which will be the first compressed tile) has a very | |
# wide range of values that will be difficult to quantize, and should | |
# result in use of a GZIP_COMPRESSED_DATA column | |
arr[0] = np.linspace(0, 1, 7000) | |
arr[1] = np.random.normal(size=7000) | |
hdu = fits.CompImageHDU(data=arr) | |
hdu.writeto(self.temp('test.fits')) | |
with fits.open(self.temp('test.fits')) as hdul: | |
comp_hdu = hdul[1] | |
# GZIP-compressed tile should compare exactly | |
> assert np.all(comp_hdu.data[0] == arr[0]) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1670: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________ TestCompressedImage.test_scale_back_compressed_uint_assignment ________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x00000000189978d8> | |
def test_scale_back_compressed_uint_assignment(self): | |
""" | |
Extend fix for #4600 to assignment to data | |
Identical to test_scale_back_uint_assignment() but uses a compressed | |
image. | |
Suggested by: | |
https://github.com/astropy/astropy/pull/4602#issuecomment-208713748 | |
""" | |
a = np.arange(100, 200, dtype=np.uint16) | |
fits.CompImageHDU(a).writeto(self.temp('test.fits')) | |
with fits.open(self.temp('test.fits'), mode="update", | |
scale_back=True) as hdul: | |
hdul[1].data[:] = 0 | |
> assert np.allclose(hdul[1].data, 0) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1733: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____ TestCompressedImage.test_compressed_scaled_float[BSCALE-uint8-float32] ____ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x000000000c519b08> | |
keyword = 'BSCALE', dtype = <class 'numpy.uint8'> | |
expected = <class 'numpy.float32'> | |
@pytest.mark.parametrize( | |
('keyword', 'dtype', 'expected'), | |
[('BSCALE', np.uint8, np.float32), ('BSCALE', np.int16, np.float32), | |
('BSCALE', np.int32, np.float64), ('BZERO', np.uint8, np.float32), | |
('BZERO', np.int16, np.float32), ('BZERO', np.int32, np.float64)]) | |
def test_compressed_scaled_float(self, keyword, dtype, expected): | |
""" | |
If BSCALE,BZERO is set to floating point values, the image | |
should be floating-point. | |
https://github.com/astropy/astropy/pull/6492 | |
Parameters | |
---------- | |
keyword : `str` | |
Keyword to set to a floating-point value to trigger | |
floating-point pixels. | |
dtype : `numpy.dtype` | |
Type of original array. | |
expected : `numpy.dtype` | |
Expected type of uncompressed array. | |
""" | |
value = 1.23345 # A floating-point value | |
hdu = fits.CompImageHDU(np.arange(0, 10, dtype=dtype)) | |
hdu.header[keyword] = value | |
hdu.writeto(self.temp('test.fits')) | |
del hdu | |
with fits.open(self.temp('test.fits')) as hdu: | |
assert hdu[1].header[keyword] == value | |
> assert hdu[1].data.dtype == expected | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1775: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____ TestCompressedImage.test_compressed_scaled_float[BSCALE-int16-float32] ____ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x0000000008cff398> | |
keyword = 'BSCALE', dtype = <class 'numpy.int16'> | |
expected = <class 'numpy.float32'> | |
@pytest.mark.parametrize( | |
('keyword', 'dtype', 'expected'), | |
[('BSCALE', np.uint8, np.float32), ('BSCALE', np.int16, np.float32), | |
('BSCALE', np.int32, np.float64), ('BZERO', np.uint8, np.float32), | |
('BZERO', np.int16, np.float32), ('BZERO', np.int32, np.float64)]) | |
def test_compressed_scaled_float(self, keyword, dtype, expected): | |
""" | |
If BSCALE,BZERO is set to floating point values, the image | |
should be floating-point. | |
https://github.com/astropy/astropy/pull/6492 | |
Parameters | |
---------- | |
keyword : `str` | |
Keyword to set to a floating-point value to trigger | |
floating-point pixels. | |
dtype : `numpy.dtype` | |
Type of original array. | |
expected : `numpy.dtype` | |
Expected type of uncompressed array. | |
""" | |
value = 1.23345 # A floating-point value | |
hdu = fits.CompImageHDU(np.arange(0, 10, dtype=dtype)) | |
hdu.header[keyword] = value | |
hdu.writeto(self.temp('test.fits')) | |
del hdu | |
with fits.open(self.temp('test.fits')) as hdu: | |
assert hdu[1].header[keyword] == value | |
> assert hdu[1].data.dtype == expected | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1775: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____ TestCompressedImage.test_compressed_scaled_float[BSCALE-int32-float64] ____ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x000000000cf32720> | |
keyword = 'BSCALE', dtype = <class 'numpy.int32'> | |
expected = <class 'numpy.float64'> | |
@pytest.mark.parametrize( | |
('keyword', 'dtype', 'expected'), | |
[('BSCALE', np.uint8, np.float32), ('BSCALE', np.int16, np.float32), | |
('BSCALE', np.int32, np.float64), ('BZERO', np.uint8, np.float32), | |
('BZERO', np.int16, np.float32), ('BZERO', np.int32, np.float64)]) | |
def test_compressed_scaled_float(self, keyword, dtype, expected): | |
""" | |
If BSCALE,BZERO is set to floating point values, the image | |
should be floating-point. | |
https://github.com/astropy/astropy/pull/6492 | |
Parameters | |
---------- | |
keyword : `str` | |
Keyword to set to a floating-point value to trigger | |
floating-point pixels. | |
dtype : `numpy.dtype` | |
Type of original array. | |
expected : `numpy.dtype` | |
Expected type of uncompressed array. | |
""" | |
value = 1.23345 # A floating-point value | |
hdu = fits.CompImageHDU(np.arange(0, 10, dtype=dtype)) | |
hdu.header[keyword] = value | |
hdu.writeto(self.temp('test.fits')) | |
del hdu | |
with fits.open(self.temp('test.fits')) as hdu: | |
assert hdu[1].header[keyword] == value | |
> assert hdu[1].data.dtype == expected | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1775: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____ TestCompressedImage.test_compressed_scaled_float[BZERO-uint8-float32] _____ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x0000000013ded168> | |
keyword = 'BZERO', dtype = <class 'numpy.uint8'> | |
expected = <class 'numpy.float32'> | |
@pytest.mark.parametrize( | |
('keyword', 'dtype', 'expected'), | |
[('BSCALE', np.uint8, np.float32), ('BSCALE', np.int16, np.float32), | |
('BSCALE', np.int32, np.float64), ('BZERO', np.uint8, np.float32), | |
('BZERO', np.int16, np.float32), ('BZERO', np.int32, np.float64)]) | |
def test_compressed_scaled_float(self, keyword, dtype, expected): | |
""" | |
If BSCALE,BZERO is set to floating point values, the image | |
should be floating-point. | |
https://github.com/astropy/astropy/pull/6492 | |
Parameters | |
---------- | |
keyword : `str` | |
Keyword to set to a floating-point value to trigger | |
floating-point pixels. | |
dtype : `numpy.dtype` | |
Type of original array. | |
expected : `numpy.dtype` | |
Expected type of uncompressed array. | |
""" | |
value = 1.23345 # A floating-point value | |
hdu = fits.CompImageHDU(np.arange(0, 10, dtype=dtype)) | |
hdu.header[keyword] = value | |
hdu.writeto(self.temp('test.fits')) | |
del hdu | |
with fits.open(self.temp('test.fits')) as hdu: | |
assert hdu[1].header[keyword] == value | |
> assert hdu[1].data.dtype == expected | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1775: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____ TestCompressedImage.test_compressed_scaled_float[BZERO-int16-float32] _____ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x000000001696a918> | |
keyword = 'BZERO', dtype = <class 'numpy.int16'> | |
expected = <class 'numpy.float32'> | |
@pytest.mark.parametrize( | |
('keyword', 'dtype', 'expected'), | |
[('BSCALE', np.uint8, np.float32), ('BSCALE', np.int16, np.float32), | |
('BSCALE', np.int32, np.float64), ('BZERO', np.uint8, np.float32), | |
('BZERO', np.int16, np.float32), ('BZERO', np.int32, np.float64)]) | |
def test_compressed_scaled_float(self, keyword, dtype, expected): | |
""" | |
If BSCALE,BZERO is set to floating point values, the image | |
should be floating-point. | |
https://github.com/astropy/astropy/pull/6492 | |
Parameters | |
---------- | |
keyword : `str` | |
Keyword to set to a floating-point value to trigger | |
floating-point pixels. | |
dtype : `numpy.dtype` | |
Type of original array. | |
expected : `numpy.dtype` | |
Expected type of uncompressed array. | |
""" | |
value = 1.23345 # A floating-point value | |
hdu = fits.CompImageHDU(np.arange(0, 10, dtype=dtype)) | |
hdu.header[keyword] = value | |
hdu.writeto(self.temp('test.fits')) | |
del hdu | |
with fits.open(self.temp('test.fits')) as hdu: | |
assert hdu[1].header[keyword] == value | |
> assert hdu[1].data.dtype == expected | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1775: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____ TestCompressedImage.test_compressed_scaled_float[BZERO-int32-float64] _____ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x00000000185de560> | |
keyword = 'BZERO', dtype = <class 'numpy.int32'> | |
expected = <class 'numpy.float64'> | |
@pytest.mark.parametrize( | |
('keyword', 'dtype', 'expected'), | |
[('BSCALE', np.uint8, np.float32), ('BSCALE', np.int16, np.float32), | |
('BSCALE', np.int32, np.float64), ('BZERO', np.uint8, np.float32), | |
('BZERO', np.int16, np.float32), ('BZERO', np.int32, np.float64)]) | |
def test_compressed_scaled_float(self, keyword, dtype, expected): | |
""" | |
If BSCALE,BZERO is set to floating point values, the image | |
should be floating-point. | |
https://github.com/astropy/astropy/pull/6492 | |
Parameters | |
---------- | |
keyword : `str` | |
Keyword to set to a floating-point value to trigger | |
floating-point pixels. | |
dtype : `numpy.dtype` | |
Type of original array. | |
expected : `numpy.dtype` | |
Expected type of uncompressed array. | |
""" | |
value = 1.23345 # A floating-point value | |
hdu = fits.CompImageHDU(np.arange(0, 10, dtype=dtype)) | |
hdu.header[keyword] = value | |
hdu.writeto(self.temp('test.fits')) | |
del hdu | |
with fits.open(self.temp('test.fits')) as hdu: | |
assert hdu[1].header[keyword] == value | |
> assert hdu[1].data.dtype == expected | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1775: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________ TestCompressedImage.test_compressed_integers[uint8] ______________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x0000000018a56448> | |
dtype = <class 'numpy.uint8'> | |
@pytest.mark.parametrize('dtype', (np.uint8, np.int16, np.uint16, np.int32, | |
np.uint32)) | |
def test_compressed_integers(self, dtype): | |
"""Test that the various integer dtypes are correctly written and read. | |
Regression test for https://github.com/astropy/astropy/issues/9072 | |
""" | |
mid = np.iinfo(dtype).max // 2 | |
data = np.arange(mid-50, mid+50, dtype=dtype) | |
testfile = self.temp('test.fits') | |
hdu = fits.CompImageHDU(data=data) | |
hdu.writeto(testfile, overwrite=True) | |
> new = fits.getdata(testfile) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1790: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/convenience.py:204: in getdata | |
hdulist.close(closed=closed) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________ TestCompressedImage.test_compressed_integers[int16] ______________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x000000001c2574b0> | |
dtype = <class 'numpy.int16'> | |
@pytest.mark.parametrize('dtype', (np.uint8, np.int16, np.uint16, np.int32, | |
np.uint32)) | |
def test_compressed_integers(self, dtype): | |
"""Test that the various integer dtypes are correctly written and read. | |
Regression test for https://github.com/astropy/astropy/issues/9072 | |
""" | |
mid = np.iinfo(dtype).max // 2 | |
data = np.arange(mid-50, mid+50, dtype=dtype) | |
testfile = self.temp('test.fits') | |
hdu = fits.CompImageHDU(data=data) | |
hdu.writeto(testfile, overwrite=True) | |
> new = fits.getdata(testfile) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1790: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/convenience.py:204: in getdata | |
hdulist.close(closed=closed) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________ TestCompressedImage.test_compressed_integers[uint16] _____________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x00000000133c8138> | |
dtype = <class 'numpy.uint16'> | |
@pytest.mark.parametrize('dtype', (np.uint8, np.int16, np.uint16, np.int32, | |
np.uint32)) | |
def test_compressed_integers(self, dtype): | |
"""Test that the various integer dtypes are correctly written and read. | |
Regression test for https://github.com/astropy/astropy/issues/9072 | |
""" | |
mid = np.iinfo(dtype).max // 2 | |
data = np.arange(mid-50, mid+50, dtype=dtype) | |
testfile = self.temp('test.fits') | |
hdu = fits.CompImageHDU(data=data) | |
hdu.writeto(testfile, overwrite=True) | |
> new = fits.getdata(testfile) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1790: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/convenience.py:204: in getdata | |
hdulist.close(closed=closed) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________ TestCompressedImage.test_compressed_integers[int32] ______________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x0000000011338288> | |
dtype = <class 'numpy.int32'> | |
@pytest.mark.parametrize('dtype', (np.uint8, np.int16, np.uint16, np.int32, | |
np.uint32)) | |
def test_compressed_integers(self, dtype): | |
"""Test that the various integer dtypes are correctly written and read. | |
Regression test for https://github.com/astropy/astropy/issues/9072 | |
""" | |
mid = np.iinfo(dtype).max // 2 | |
data = np.arange(mid-50, mid+50, dtype=dtype) | |
testfile = self.temp('test.fits') | |
hdu = fits.CompImageHDU(data=data) | |
hdu.writeto(testfile, overwrite=True) | |
> new = fits.getdata(testfile) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1790: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/convenience.py:204: in getdata | |
hdulist.close(closed=closed) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________ TestCompressedImage.test_compressed_integers[uint32] _____________ | |
self = <astropy.io.fits.tests.test_image.TestCompressedImage object at 0x000000001aead088> | |
dtype = <class 'numpy.uint32'> | |
@pytest.mark.parametrize('dtype', (np.uint8, np.int16, np.uint16, np.int32, | |
np.uint32)) | |
def test_compressed_integers(self, dtype): | |
"""Test that the various integer dtypes are correctly written and read. | |
Regression test for https://github.com/astropy/astropy/issues/9072 | |
""" | |
mid = np.iinfo(dtype).max // 2 | |
data = np.arange(mid-50, mid+50, dtype=dtype) | |
testfile = self.temp('test.fits') | |
hdu = fits.CompImageHDU(data=data) | |
hdu.writeto(testfile, overwrite=True) | |
> new = fits.getdata(testfile) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1790: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/convenience.py:204: in getdata | |
hdulist.close(closed=closed) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________________________ test_comphdu_bscale ______________________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_comphdu_bscale0') | |
def test_comphdu_bscale(tmpdir): | |
""" | |
Regression test for a bug that caused extensions that used BZERO and BSCALE | |
that got turned into CompImageHDU to end up with BZERO/BSCALE before the | |
TFIELDS. | |
""" | |
filename1 = tmpdir.join('3hdus.fits').strpath | |
filename2 = tmpdir.join('3hdus_comp.fits').strpath | |
x = np.random.random((100, 100))*100 | |
x0 = fits.PrimaryHDU() | |
x1 = fits.ImageHDU(np.array(x-50, dtype=int), uint=True) | |
x1.header['BZERO'] = 20331 | |
x1.header['BSCALE'] = 2.3 | |
hdus = fits.HDUList([x0, x1]) | |
hdus.writeto(filename1) | |
# fitsverify (based on cfitsio) should fail on this file, only seeing the | |
# first HDU. | |
with fits.open(filename1) as hdus: | |
hdus[1] = fits.CompImageHDU(data=hdus[1].data.astype(np.uint32), | |
header=hdus[1].header) | |
> hdus.writeto(filename2) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1818: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________________ test_bzero_implicit_casting_compressed ____________________ | |
def test_bzero_implicit_casting_compressed(): | |
# Regression test for an issue that occurred because Numpy now does not | |
# allow implicit type casting during inplace operations. Astropy is | |
# actually not able to produce a file that triggers the failure - the | |
# issue occurs when using unsigned integer types in the FITS file, in which | |
# case BZERO should be 32768. But if the keyword is stored as 32768.0, then | |
# it was possible to trigger the implicit casting error. | |
filename = os.path.join(os.path.dirname(__file__), | |
'data', 'compressed_float_bzero.fits') | |
with fits.open(filename) as hdul: | |
hdu = hdul[1] | |
> hdu.data | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1848: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________________________ test_image_write_readonly ___________________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_image_write_readonly0') | |
def test_image_write_readonly(tmpdir): | |
# Regression test to make sure that we can write out read-only arrays (#5512) | |
x = np.array([1, 2, 3]) | |
x.setflags(write=False) | |
ghdu = fits.ImageHDU(data=x) | |
ghdu.add_datasum() | |
filename = tmpdir.join('test.fits').strpath | |
ghdu.writeto(filename) | |
with fits.open(filename) as hdulist: | |
> assert_equal(hdulist[1].data, [1, 2, 3]) | |
pypy/site-packages/astropy/io/fits/tests/test_image.py:1878: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ TestNonstandardHdus.test_create_fitshdu ____________________ | |
self = <astropy.io.fits.tests.test_nonstandard.TestNonstandardHdus object at 0x0000000010228ad8> | |
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) | |
pypy/site-packages/astropy/io/fits/tests/test_nonstandard.py:17: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/tests/test_nonstandard.py:68: in _test_create_fitshdu | |
hdul_orig.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________ TestNonstandardHdus.test_create_fitshdu_with_compression ___________ | |
self = <astropy.io.fits.tests.test_nonstandard.TestNonstandardHdus object at 0x000000000cc663a0> | |
def test_create_fitshdu_with_compression(self): | |
"""Same as test_create_fitshdu but with gzip compression enabled.""" | |
> self._test_create_fitshdu(compression=True) | |
pypy/site-packages/astropy/io/fits/tests/test_nonstandard.py:22: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/tests/test_nonstandard.py:68: in _test_create_fitshdu | |
hdul_orig.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________ TestNonstandardHdus.test_create_fitshdu_from_filename _____________ | |
self = <astropy.io.fits.tests.test_nonstandard.TestNonstandardHdus object at 0x000000000df9ec60> | |
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')) | |
pypy/site-packages/astropy/io/fits/tests/test_nonstandard.py:39: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/nonstandard.py:56: in fromfile | |
return cls.fromhdulist(hdulist, compress=compress) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________________ TestStructured.test_structured ________________________ | |
self = <astropy.io.fits.tests.test_structured.TestStructured object at 0x000000000d793910> | |
def test_structured(self): | |
fname = self.data('stddata.fits') | |
> data1, h1 = fits.getdata(fname, ext=1, header=True) | |
pypy/site-packages/astropy/io/fits/tests/test_structured.py:77: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/convenience.py:204: in getdata | |
hdulist.close(closed=closed) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________________ TestTableFunctions.test_open _________________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000000e069e88> | |
def test_open(self): | |
# open some existing FITS files: | |
tt = fits.open(self.data('tb.fits')) | |
fd = fits.open(self.data('test0.fits')) | |
# create some local arrays | |
a1 = chararray.array(['abc', 'def', 'xx']) | |
r1 = np.array([11., 12., 13.], dtype=np.float32) | |
# create a table from scratch, using a mixture of columns from existing | |
# tables and locally created arrays: | |
# first, create individual column definitions | |
c1 = fits.Column(name='abc', format='3A', array=a1) | |
c2 = fits.Column(name='def', format='E', array=r1) | |
a3 = np.array([3, 4, 5], dtype='i2') | |
c3 = fits.Column(name='xyz', format='I', array=a3) | |
a4 = np.array([1, 2, 3], dtype='i2') | |
c4 = fits.Column(name='t1', format='I', array=a4) | |
a5 = np.array([3 + 3j, 4 + 4j, 5 + 5j], dtype='c8') | |
c5 = fits.Column(name='t2', format='C', array=a5) | |
# Note that X format must be two-D array | |
a6 = np.array([[0], [1], [0]], dtype=np.uint8) | |
c6 = fits.Column(name='t3', format='X', array=a6) | |
a7 = np.array([101, 102, 103], dtype='i4') | |
c7 = fits.Column(name='t4', format='J', array=a7) | |
a8 = np.array([[1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1], | |
[0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0], | |
[1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1]], dtype=np.uint8) | |
c8 = fits.Column(name='t5', format='11X', array=a8) | |
# second, create a column-definitions object for all columns in a table | |
x = fits.ColDefs([c1, c2, c3, c4, c5, c6, c7, c8]) | |
tbhdu = fits.BinTableHDU.from_columns(x) | |
# another way to create a table is by using existing table's | |
# information: | |
x2 = fits.ColDefs(tt[1]) | |
t2 = fits.BinTableHDU.from_columns(x2, nrows=2) | |
ra = np.rec.array([ | |
(1, 'abc', 3.7000002861022949, 0), | |
(2, 'xy ', 6.6999998092651367, 1)], names='c1, c2, c3, c4') | |
assert comparerecords(t2.data, ra) | |
# the table HDU's data is a subclass of a record array, so we can | |
# access one row like this: | |
assert tbhdu.data[1][0] == a1[1] | |
assert tbhdu.data[1][1] == r1[1] | |
assert tbhdu.data[1][2] == a3[1] | |
assert tbhdu.data[1][3] == a4[1] | |
assert tbhdu.data[1][4] == a5[1] | |
assert (tbhdu.data[1][5] == a6[1].view('bool')).all() | |
assert tbhdu.data[1][6] == a7[1] | |
assert (tbhdu.data[1][7] == a8[1]).all() | |
# and a column like this: | |
assert str(tbhdu.data.field('abc')) == "['abc' 'def' 'xx']" | |
# An alternative way to create a column-definitions object is from an | |
# existing table. | |
_ = fits.ColDefs(tt[1]) | |
# now we write out the newly created table HDU to a FITS file: | |
fout = fits.HDUList(fits.PrimaryHDU()) | |
fout.append(tbhdu) | |
fout.writeto(self.temp('tableout1.fits'), overwrite=True) | |
with fits.open(self.temp('tableout1.fits')) as f2: | |
temp = f2[1].data.field(7) | |
> assert (temp[0] == [True, True, False, True, False, True, | |
True, True, False, False, True]).all() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:205: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________________ TestTableFunctions.test_binary_table _____________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x0000000018d30368> | |
def test_binary_table(self): | |
# binary table: | |
t = fits.open(self.data('tb.fits')) | |
assert t[1].header['tform1'] == '1J' | |
info = {'name': ['c1', 'c2', 'c3', 'c4'], | |
'format': ['1J', '3A', '1E', '1L'], | |
'unit': ['', '', '', ''], | |
'null': [-2147483647, '', '', ''], | |
'bscale': ['', '', 3, ''], | |
'bzero': ['', '', 0.4, ''], | |
'disp': ['I11', 'A3', 'G15.7', 'L6'], | |
'start': ['', '', '', ''], | |
'dim': ['', '', '', ''], | |
'coord_inc': ['', '', '', ''], | |
'coord_type': ['', '', '', ''], | |
'coord_unit': ['', '', '', ''], | |
'coord_ref_point': ['', '', '', ''], | |
'coord_ref_value': ['', '', '', ''], | |
'time_ref_pos': ['', '', '', '']} | |
assert t[1].columns.info(output=False) == info | |
ra = np.rec.array([ | |
(1, 'abc', 3.7000002861022949, 0), | |
(2, 'xy ', 6.6999998092651367, 1)], names='c1, c2, c3, c4') | |
assert comparerecords(t[1].data, ra[:2]) | |
# Change scaled field and scale back to the original array | |
t[1].data.field('c4')[0] = 1 | |
t[1].data._scale_back() | |
assert str(np.rec.recarray.field(t[1].data, 'c4')) == '[84 84]' | |
# look at data column-wise | |
assert (t[1].data.field(0) == np.array([1, 2])).all() | |
# When there are scaled columns, the raw data are in data._parent | |
> t.close() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:255: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________________ TestTableFunctions.test_ascii_table ______________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000001908d6e0> | |
def test_ascii_table(self): | |
# ASCII table | |
a = fits.open(self.data('ascii.fits')) | |
ra1 = np.rec.array([ | |
(10.123000144958496, 37), | |
(5.1999998092651367, 23), | |
(15.609999656677246, 17), | |
(0.0, 0), | |
(345.0, 345)], names='c1, c2') | |
assert comparerecords(a[1].data, ra1) | |
# Test slicing | |
a2 = a[1].data[2:][2:] | |
ra2 = np.rec.array([(345.0, 345)], names='c1, c2') | |
assert comparerecords(a2, ra2) | |
assert (a2.field(1) == np.array([345])).all() | |
ra3 = np.rec.array([ | |
(10.123000144958496, 37), | |
(15.609999656677246, 17), | |
(345.0, 345) | |
], names='c1, c2') | |
assert comparerecords(a[1].data[::2], ra3) | |
# Test Start Column | |
a1 = chararray.array(['abcd', 'def']) | |
r1 = np.array([11., 12.]) | |
c1 = fits.Column(name='abc', format='A3', start=19, array=a1) | |
c2 = fits.Column(name='def', format='E', start=3, array=r1) | |
c3 = fits.Column(name='t1', format='I', array=[91, 92, 93]) | |
hdu = fits.TableHDU.from_columns([c2, c1, c3]) | |
assert (dict(hdu.data.dtype.fields) == | |
{'abc': (np.dtype('|S3'), 18), | |
'def': (np.dtype('|S15'), 2), | |
't1': (np.dtype('|S10'), 21)}) | |
hdu.writeto(self.temp('toto.fits'), overwrite=True) | |
hdul = fits.open(self.temp('toto.fits')) | |
assert comparerecords(hdu.data, hdul[1].data) | |
> hdul.close() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:300: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________________ TestTableFunctions.test_endianness ______________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x0000000022b9e950> | |
def test_endianness(self): | |
x = np.ndarray((1,), dtype=object) | |
channelsIn = np.array([3], dtype='uint8') | |
x[0] = channelsIn | |
col = fits.Column(name="Channels", format="PB()", array=x) | |
cols = fits.ColDefs([col]) | |
tbhdu = fits.BinTableHDU.from_columns(cols) | |
tbhdu.name = "RFI" | |
tbhdu.writeto(self.temp('testendian.fits'), overwrite=True) | |
hduL = fits.open(self.temp('testendian.fits')) | |
rfiHDU = hduL['RFI'] | |
data = rfiHDU.data | |
channelsOut = data.field('Channels')[0] | |
assert (channelsIn == channelsOut).all() | |
> hduL.close() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:330: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________________ TestTableFunctions.test_column_endianness ___________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000001241fde0> | |
def test_column_endianness(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/77 | |
(Astropy doesn't preserve byte order of non-native order column arrays) | |
""" | |
a = [1., 2., 3., 4.] | |
a1 = np.array(a, dtype='<f8') | |
a2 = np.array(a, dtype='>f8') | |
col1 = fits.Column(name='a', format='D', array=a1) | |
col2 = fits.Column(name='b', format='D', array=a2) | |
cols = fits.ColDefs([col1, col2]) | |
tbhdu = fits.BinTableHDU.from_columns(cols) | |
assert (tbhdu.data['a'] == a1).all() | |
assert (tbhdu.data['b'] == a2).all() | |
# Double check that the array is converted to the correct byte-order | |
# for FITS (big-endian). | |
tbhdu.writeto(self.temp('testendian.fits'), overwrite=True) | |
with fits.open(self.temp('testendian.fits')) as hdul: | |
assert (hdul[1].data['a'] == a2).all() | |
> assert (hdul[1].data['b'] == a2).all() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:355: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________ TestTableFunctions.test_recarray_to_bintablehdu ________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x0000000013364330> | |
def test_recarray_to_bintablehdu(self): | |
bright = np.rec.array( | |
[(1, 'Serius', -1.45, 'A1V'), | |
(2, 'Canopys', -0.73, 'F0Ib'), | |
(3, 'Rigil Kent', -0.1, 'G2V')], | |
formats='int16,a20,float32,a10', | |
names='order,name,mag,Sp') | |
hdu = fits.BinTableHDU(bright) | |
assert comparerecords(hdu.data, bright) | |
hdu.writeto(self.temp('toto.fits'), overwrite=True) | |
hdul = fits.open(self.temp('toto.fits')) | |
assert comparerecords(hdu.data, hdul[1].data) | |
assert comparerecords(bright, hdul[1].data) | |
> hdul.close() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:370: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________ TestTableFunctions.test_numpy_ndarray_to_bintablehdu _____________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x0000000019a7ae20> | |
def test_numpy_ndarray_to_bintablehdu(self): | |
desc = np.dtype({'names': ['order', 'name', 'mag', 'Sp'], | |
'formats': ['int', 'S20', 'float32', 'S10']}) | |
a = np.array([(1, 'Serius', -1.45, 'A1V'), | |
(2, 'Canopys', -0.73, 'F0Ib'), | |
(3, 'Rigil Kent', -0.1, 'G2V')], dtype=desc) | |
hdu = fits.BinTableHDU(a) | |
assert comparerecords(hdu.data, a.view(fits.FITS_rec)) | |
hdu.writeto(self.temp('toto.fits'), overwrite=True) | |
hdul = fits.open(self.temp('toto.fits')) | |
assert comparerecords(hdu.data, hdul[1].data) | |
> hdul.close() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:383: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______ TestTableFunctions.test_numpy_ndarray_to_bintablehdu_with_unicode _______ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000000d2b3ec0> | |
def test_numpy_ndarray_to_bintablehdu_with_unicode(self): | |
desc = np.dtype({'names': ['order', 'name', 'mag', 'Sp'], | |
'formats': ['int', 'U20', 'float32', 'U10']}) | |
a = np.array([(1, 'Serius', -1.45, 'A1V'), | |
(2, 'Canopys', -0.73, 'F0Ib'), | |
(3, 'Rigil Kent', -0.1, 'G2V')], dtype=desc) | |
hdu = fits.BinTableHDU(a) | |
assert comparerecords(hdu.data, a.view(fits.FITS_rec)) | |
hdu.writeto(self.temp('toto.fits'), overwrite=True) | |
hdul = fits.open(self.temp('toto.fits')) | |
assert comparerecords(hdu.data, hdul[1].data) | |
> hdul.close() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:396: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________ TestTableFunctions.test_new_table_from_recarray ________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000000dba8090> | |
def test_new_table_from_recarray(self): | |
bright = np.rec.array([(1, 'Serius', -1.45, 'A1V'), | |
(2, 'Canopys', -0.73, 'F0Ib'), | |
(3, 'Rigil Kent', -0.1, 'G2V')], | |
formats='int16,a20,float64,a10', | |
names='order,name,mag,Sp') | |
hdu = fits.TableHDU.from_columns(bright, nrows=2) | |
# Verify that all ndarray objects within the HDU reference the | |
# same ndarray. | |
assert (id(hdu.data._coldefs.columns[0].array) == | |
id(hdu.data._coldefs._arrays[0])) | |
assert (id(hdu.data._coldefs.columns[0].array) == | |
id(hdu.columns.columns[0].array)) | |
assert (id(hdu.data._coldefs.columns[0].array) == | |
id(hdu.columns._arrays[0])) | |
# Ensure I can change the value of one data element and it effects | |
# all of the others. | |
hdu.data[0][0] = 213 | |
assert hdu.data[0][0] == 213 | |
assert hdu.data._coldefs._arrays[0][0] == 213 | |
assert hdu.data._coldefs.columns[0].array[0] == 213 | |
assert hdu.columns._arrays[0][0] == 213 | |
assert hdu.columns.columns[0].array[0] == 213 | |
hdu.data._coldefs._arrays[0][0] = 100 | |
assert hdu.data[0][0] == 100 | |
assert hdu.data._coldefs._arrays[0][0] == 100 | |
assert hdu.data._coldefs.columns[0].array[0] == 100 | |
assert hdu.columns._arrays[0][0] == 100 | |
assert hdu.columns.columns[0].array[0] == 100 | |
hdu.data._coldefs.columns[0].array[0] = 500 | |
assert hdu.data[0][0] == 500 | |
assert hdu.data._coldefs._arrays[0][0] == 500 | |
assert hdu.data._coldefs.columns[0].array[0] == 500 | |
assert hdu.columns._arrays[0][0] == 500 | |
assert hdu.columns.columns[0].array[0] == 500 | |
hdu.columns._arrays[0][0] = 600 | |
assert hdu.data[0][0] == 600 | |
assert hdu.data._coldefs._arrays[0][0] == 600 | |
assert hdu.data._coldefs.columns[0].array[0] == 600 | |
assert hdu.columns._arrays[0][0] == 600 | |
assert hdu.columns.columns[0].array[0] == 600 | |
hdu.columns.columns[0].array[0] = 800 | |
assert hdu.data[0][0] == 800 | |
assert hdu.data._coldefs._arrays[0][0] == 800 | |
assert hdu.data._coldefs.columns[0].array[0] == 800 | |
assert hdu.columns._arrays[0][0] == 800 | |
assert hdu.columns.columns[0].array[0] == 800 | |
assert (hdu.data.field(0) == | |
np.array([800, 2], dtype=np.int16)).all() | |
assert hdu.data[0][1] == 'Serius' | |
assert hdu.data[1][1] == 'Canopys' | |
assert (hdu.data.field(2) == | |
np.array([-1.45, -0.73], dtype=np.float64)).all() | |
assert hdu.data[0][3] == 'A1V' | |
assert hdu.data[1][3] == 'F0Ib' | |
with ignore_warnings(): | |
hdu.writeto(self.temp('toto.fits'), overwrite=True) | |
with fits.open(self.temp('toto.fits')) as hdul: | |
assert (hdul[1].data.field(0) == | |
np.array([800, 2], dtype=np.int16)).all() | |
assert hdul[1].data[0][1] == 'Serius' | |
assert hdul[1].data[1][1] == 'Canopys' | |
assert (hdul[1].data.field(2) == | |
np.array([-1.45, -0.73], dtype=np.float64)).all() | |
assert hdul[1].data[0][3] == 'A1V' | |
> assert hdul[1].data[1][3] == 'F0Ib' | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:474: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________________ TestTableFunctions.test_new_fitsrec ______________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000000d5d26e8> | |
def test_new_fitsrec(self): | |
""" | |
Tests creating a new FITS_rec object from a multi-field ndarray. | |
""" | |
with fits.open(self.data('tb.fits')) as h: | |
> data = h[1].data | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:494: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________________ TestTableFunctions.test_appending_a_column __________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000000f2051a0> | |
def test_appending_a_column(self): | |
counts = np.array([312, 334, 308, 317]) | |
names = np.array(['NGC1', 'NGC2', 'NGC3', 'NCG4']) | |
c1 = fits.Column(name='target', format='10A', array=names) | |
c2 = fits.Column(name='counts', format='J', unit='DN', array=counts) | |
c3 = fits.Column(name='notes', format='A10') | |
c4 = fits.Column(name='spectrum', format='5E') | |
c5 = fits.Column(name='flag', format='L', array=[1, 0, 1, 1]) | |
coldefs = fits.ColDefs([c1, c2, c3, c4, c5]) | |
tbhdu = fits.BinTableHDU.from_columns(coldefs) | |
tbhdu.writeto(self.temp('table1.fits')) | |
counts = np.array([412, 434, 408, 417]) | |
names = np.array(['NGC5', 'NGC6', 'NGC7', 'NCG8']) | |
c1 = fits.Column(name='target', format='10A', array=names) | |
c2 = fits.Column(name='counts', format='J', unit='DN', array=counts) | |
c3 = fits.Column(name='notes', format='A10') | |
c4 = fits.Column(name='spectrum', format='5E') | |
c5 = fits.Column(name='flag', format='L', array=[0, 1, 0, 0]) | |
coldefs = fits.ColDefs([c1, c2, c3, c4, c5]) | |
tbhdu = fits.BinTableHDU.from_columns(coldefs) | |
tbhdu.writeto(self.temp('table2.fits')) | |
# Append the rows of table 2 after the rows of table 1 | |
# The column definitions are assumed to be the same | |
# Open the two files we want to append | |
t1 = fits.open(self.temp('table1.fits')) | |
t2 = fits.open(self.temp('table2.fits')) | |
# Get the number of rows in the table from the first file | |
nrows1 = t1[1].data.shape[0] | |
# Get the total number of rows in the resulting appended table | |
nrows = t1[1].data.shape[0] + t2[1].data.shape[0] | |
assert (t1[1].columns._arrays[1] is t1[1].columns.columns[1].array) | |
# Create a new table that consists of the data from the first table | |
# but has enough space in the ndarray to hold the data from both tables | |
hdu = fits.BinTableHDU.from_columns(t1[1].columns, nrows=nrows) | |
# For each column in the tables append the data from table 2 after the | |
# data from table 1. | |
for i in range(len(t1[1].columns)): | |
hdu.data.field(i)[nrows1:] = t2[1].data.field(i) | |
hdu.writeto(self.temp('newtable.fits')) | |
info = [(0, 'PRIMARY', 1, 'PrimaryHDU', 4, (), '', ''), | |
(1, '', 1, 'BinTableHDU', 19, '8R x 5C', '[10A, J, 10A, 5E, L]', | |
'')] | |
assert fits.info(self.temp('newtable.fits'), output=False) == info | |
z = np.array([0., 0., 0., 0., 0.], dtype=np.float32) | |
array = np.rec.array( | |
[('NGC1', 312, '', z, True), | |
('NGC2', 334, '', z, False), | |
('NGC3', 308, '', z, True), | |
('NCG4', 317, '', z, True), | |
('NGC5', 412, '', z, False), | |
('NGC6', 434, '', z, True), | |
('NGC7', 408, '', z, False), | |
('NCG8', 417, '', z, False)], | |
formats='a10,u4,a10,5f4,l') | |
assert comparerecords(hdu.data, array) | |
# Verify that all of the references to the data point to the same | |
# numarray | |
hdu.data[0][1] = 300 | |
assert hdu.data._coldefs._arrays[1][0] == 300 | |
assert hdu.data._coldefs.columns[1].array[0] == 300 | |
assert hdu.columns._arrays[1][0] == 300 | |
assert hdu.columns.columns[1].array[0] == 300 | |
assert hdu.data[0][1] == 300 | |
hdu.data._coldefs._arrays[1][0] = 200 | |
assert hdu.data._coldefs._arrays[1][0] == 200 | |
assert hdu.data._coldefs.columns[1].array[0] == 200 | |
assert hdu.columns._arrays[1][0] == 200 | |
assert hdu.columns.columns[1].array[0] == 200 | |
assert hdu.data[0][1] == 200 | |
hdu.data._coldefs.columns[1].array[0] = 100 | |
assert hdu.data._coldefs._arrays[1][0] == 100 | |
assert hdu.data._coldefs.columns[1].array[0] == 100 | |
assert hdu.columns._arrays[1][0] == 100 | |
assert hdu.columns.columns[1].array[0] == 100 | |
assert hdu.data[0][1] == 100 | |
hdu.columns._arrays[1][0] = 90 | |
assert hdu.data._coldefs._arrays[1][0] == 90 | |
assert hdu.data._coldefs.columns[1].array[0] == 90 | |
assert hdu.columns._arrays[1][0] == 90 | |
assert hdu.columns.columns[1].array[0] == 90 | |
assert hdu.data[0][1] == 90 | |
hdu.columns.columns[1].array[0] = 80 | |
assert hdu.data._coldefs._arrays[1][0] == 80 | |
assert hdu.data._coldefs.columns[1].array[0] == 80 | |
assert hdu.columns._arrays[1][0] == 80 | |
assert hdu.columns.columns[1].array[0] == 80 | |
assert hdu.data[0][1] == 80 | |
# Same verification from the file | |
hdul = fits.open(self.temp('newtable.fits')) | |
hdu = hdul[1] | |
hdu.data[0][1] = 300 | |
assert hdu.data._coldefs._arrays[1][0] == 300 | |
assert hdu.data._coldefs.columns[1].array[0] == 300 | |
assert hdu.columns._arrays[1][0] == 300 | |
assert hdu.columns.columns[1].array[0] == 300 | |
assert hdu.data[0][1] == 300 | |
hdu.data._coldefs._arrays[1][0] = 200 | |
assert hdu.data._coldefs._arrays[1][0] == 200 | |
assert hdu.data._coldefs.columns[1].array[0] == 200 | |
assert hdu.columns._arrays[1][0] == 200 | |
assert hdu.columns.columns[1].array[0] == 200 | |
assert hdu.data[0][1] == 200 | |
hdu.data._coldefs.columns[1].array[0] = 100 | |
assert hdu.data._coldefs._arrays[1][0] == 100 | |
assert hdu.data._coldefs.columns[1].array[0] == 100 | |
assert hdu.columns._arrays[1][0] == 100 | |
assert hdu.columns.columns[1].array[0] == 100 | |
assert hdu.data[0][1] == 100 | |
hdu.columns._arrays[1][0] = 90 | |
assert hdu.data._coldefs._arrays[1][0] == 90 | |
assert hdu.data._coldefs.columns[1].array[0] == 90 | |
assert hdu.columns._arrays[1][0] == 90 | |
assert hdu.columns.columns[1].array[0] == 90 | |
assert hdu.data[0][1] == 90 | |
hdu.columns.columns[1].array[0] = 80 | |
assert hdu.data._coldefs._arrays[1][0] == 80 | |
assert hdu.data._coldefs.columns[1].array[0] == 80 | |
assert hdu.columns._arrays[1][0] == 80 | |
assert hdu.columns.columns[1].array[0] == 80 | |
assert hdu.data[0][1] == 80 | |
> t1.close() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:647: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________________ TestTableFunctions.test_merge_tables _____________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x0000000018c19558> | |
def test_merge_tables(self): | |
counts = np.array([312, 334, 308, 317]) | |
names = np.array(['NGC1', 'NGC2', 'NGC3', 'NCG4']) | |
c1 = fits.Column(name='target', format='10A', array=names) | |
c2 = fits.Column(name='counts', format='J', unit='DN', array=counts) | |
c3 = fits.Column(name='notes', format='A10') | |
c4 = fits.Column(name='spectrum', format='5E') | |
c5 = fits.Column(name='flag', format='L', array=[1, 0, 1, 1]) | |
coldefs = fits.ColDefs([c1, c2, c3, c4, c5]) | |
tbhdu = fits.BinTableHDU.from_columns(coldefs) | |
tbhdu.writeto(self.temp('table1.fits')) | |
counts = np.array([412, 434, 408, 417]) | |
names = np.array(['NGC5', 'NGC6', 'NGC7', 'NCG8']) | |
c1 = fits.Column(name='target1', format='10A', array=names) | |
c2 = fits.Column(name='counts1', format='J', unit='DN', array=counts) | |
c3 = fits.Column(name='notes1', format='A10') | |
c4 = fits.Column(name='spectrum1', format='5E') | |
c5 = fits.Column(name='flag1', format='L', array=[0, 1, 0, 0]) | |
coldefs = fits.ColDefs([c1, c2, c3, c4, c5]) | |
tbhdu = fits.BinTableHDU.from_columns(coldefs) | |
tbhdu.writeto(self.temp('table2.fits')) | |
# Merge the columns of table 2 after the columns of table 1 | |
# The column names are assumed to be different | |
# Open the two files we want to append | |
t1 = fits.open(self.temp('table1.fits')) | |
t2 = fits.open(self.temp('table2.fits')) | |
hdu = fits.BinTableHDU.from_columns(t1[1].columns + t2[1].columns) | |
z = np.array([0., 0., 0., 0., 0.], dtype=np.float32) | |
array = np.rec.array( | |
[('NGC1', 312, '', z, True, 'NGC5', 412, '', z, False), | |
('NGC2', 334, '', z, False, 'NGC6', 434, '', z, True), | |
('NGC3', 308, '', z, True, 'NGC7', 408, '', z, False), | |
('NCG4', 317, '', z, True, 'NCG8', 417, '', z, False)], | |
formats='a10,u4,a10,5f4,l,a10,u4,a10,5f4,l') | |
assert comparerecords(hdu.data, array) | |
hdu.writeto(self.temp('newtable.fits')) | |
# Verify that all of the references to the data point to the same | |
# numarray | |
hdu.data[0][1] = 300 | |
assert hdu.data._coldefs._arrays[1][0] == 300 | |
assert hdu.data._coldefs.columns[1].array[0] == 300 | |
assert hdu.columns._arrays[1][0] == 300 | |
assert hdu.columns.columns[1].array[0] == 300 | |
assert hdu.data[0][1] == 300 | |
hdu.data._coldefs._arrays[1][0] = 200 | |
assert hdu.data._coldefs._arrays[1][0] == 200 | |
assert hdu.data._coldefs.columns[1].array[0] == 200 | |
assert hdu.columns._arrays[1][0] == 200 | |
assert hdu.columns.columns[1].array[0] == 200 | |
assert hdu.data[0][1] == 200 | |
hdu.data._coldefs.columns[1].array[0] = 100 | |
assert hdu.data._coldefs._arrays[1][0] == 100 | |
assert hdu.data._coldefs.columns[1].array[0] == 100 | |
assert hdu.columns._arrays[1][0] == 100 | |
assert hdu.columns.columns[1].array[0] == 100 | |
assert hdu.data[0][1] == 100 | |
hdu.columns._arrays[1][0] = 90 | |
assert hdu.data._coldefs._arrays[1][0] == 90 | |
assert hdu.data._coldefs.columns[1].array[0] == 90 | |
assert hdu.columns._arrays[1][0] == 90 | |
assert hdu.columns.columns[1].array[0] == 90 | |
assert hdu.data[0][1] == 90 | |
hdu.columns.columns[1].array[0] = 80 | |
assert hdu.data._coldefs._arrays[1][0] == 80 | |
assert hdu.data._coldefs.columns[1].array[0] == 80 | |
assert hdu.columns._arrays[1][0] == 80 | |
assert hdu.columns.columns[1].array[0] == 80 | |
assert hdu.data[0][1] == 80 | |
info = [(0, 'PRIMARY', 1, 'PrimaryHDU', 4, (), '', ''), | |
(1, '', 1, 'BinTableHDU', 30, '4R x 10C', | |
'[10A, J, 10A, 5E, L, 10A, J, 10A, 5E, L]', '')] | |
assert fits.info(self.temp('newtable.fits'), output=False) == info | |
hdul = fits.open(self.temp('newtable.fits')) | |
hdu = hdul[1] | |
assert (hdu.columns.names == | |
['target', 'counts', 'notes', 'spectrum', 'flag', 'target1', | |
'counts1', 'notes1', 'spectrum1', 'flag1']) | |
z = np.array([0., 0., 0., 0., 0.], dtype=np.float32) | |
array = np.rec.array( | |
[('NGC1', 312, '', z, True, 'NGC5', 412, '', z, False), | |
('NGC2', 334, '', z, False, 'NGC6', 434, '', z, True), | |
('NGC3', 308, '', z, True, 'NGC7', 408, '', z, False), | |
('NCG4', 317, '', z, True, 'NCG8', 417, '', z, False)], | |
formats='a10,u4,a10,5f4,l,a10,u4,a10,5f4,l') | |
assert comparerecords(hdu.data, array) | |
# Same verification from the file | |
hdu.data[0][1] = 300 | |
assert hdu.data._coldefs._arrays[1][0] == 300 | |
assert hdu.data._coldefs.columns[1].array[0] == 300 | |
assert hdu.columns._arrays[1][0] == 300 | |
assert hdu.columns.columns[1].array[0] == 300 | |
assert hdu.data[0][1] == 300 | |
hdu.data._coldefs._arrays[1][0] = 200 | |
assert hdu.data._coldefs._arrays[1][0] == 200 | |
assert hdu.data._coldefs.columns[1].array[0] == 200 | |
assert hdu.columns._arrays[1][0] == 200 | |
assert hdu.columns.columns[1].array[0] == 200 | |
assert hdu.data[0][1] == 200 | |
hdu.data._coldefs.columns[1].array[0] = 100 | |
assert hdu.data._coldefs._arrays[1][0] == 100 | |
assert hdu.data._coldefs.columns[1].array[0] == 100 | |
assert hdu.columns._arrays[1][0] == 100 | |
assert hdu.columns.columns[1].array[0] == 100 | |
assert hdu.data[0][1] == 100 | |
hdu.columns._arrays[1][0] = 90 | |
assert hdu.data._coldefs._arrays[1][0] == 90 | |
assert hdu.data._coldefs.columns[1].array[0] == 90 | |
assert hdu.columns._arrays[1][0] == 90 | |
assert hdu.columns.columns[1].array[0] == 90 | |
assert hdu.data[0][1] == 90 | |
hdu.columns.columns[1].array[0] = 80 | |
assert hdu.data._coldefs._arrays[1][0] == 80 | |
assert hdu.data._coldefs.columns[1].array[0] == 80 | |
assert hdu.columns._arrays[1][0] == 80 | |
assert hdu.columns.columns[1].array[0] == 80 | |
assert hdu.data[0][1] == 80 | |
> t1.close() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:817: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________________ TestTableFunctions.test_mask_array ______________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000000f285638> | |
def test_mask_array(self): | |
t = fits.open(self.data('table.fits')) | |
tbdata = t[1].data | |
mask = tbdata.field('V_mag') > 12 | |
newtbdata = tbdata[mask] | |
hdu = fits.BinTableHDU(newtbdata) | |
hdu.writeto(self.temp('newtable.fits')) | |
hdul = fits.open(self.temp('newtable.fits')) | |
# match to a regex rather than a specific string. | |
expect = r"\[\('NGC1002',\s+12.3[0-9]*\) \(\'NGC1003\',\s+15.[0-9]+\)\]" | |
assert re.match(expect, str(hdu.data)) | |
assert re.match(expect, str(hdul[1].data)) | |
> t.close() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:862: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________________ TestTableFunctions.test_slice_a_row ______________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000001466b2f0> | |
def test_slice_a_row(self): | |
counts = np.array([312, 334, 308, 317]) | |
names = np.array(['NGC1', 'NGC2', 'NGC3', 'NCG4']) | |
c1 = fits.Column(name='target', format='10A', array=names) | |
c2 = fits.Column(name='counts', format='J', unit='DN', array=counts) | |
c3 = fits.Column(name='notes', format='A10') | |
c4 = fits.Column(name='spectrum', format='5E') | |
c5 = fits.Column(name='flag', format='L', array=[1, 0, 1, 1]) | |
coldefs = fits.ColDefs([c1, c2, c3, c4, c5]) | |
tbhdu = fits.BinTableHDU.from_columns(coldefs) | |
tbhdu.writeto(self.temp('table1.fits')) | |
t1 = fits.open(self.temp('table1.fits')) | |
row = t1[1].data[2] | |
assert row['counts'] == 308 | |
a, b, c = row[1:4] | |
assert a == counts[2] | |
assert b == '' | |
assert (c == np.array([0., 0., 0., 0., 0.], dtype=np.float32)).all() | |
row['counts'] = 310 | |
assert row['counts'] == 310 | |
row[1] = 315 | |
assert row['counts'] == 315 | |
assert row[1:4]['counts'] == 315 | |
pytest.raises(KeyError, lambda r: r[1:4]['flag'], row) | |
row[1:4]['counts'] = 300 | |
assert row[1:4]['counts'] == 300 | |
assert row['counts'] == 300 | |
row[1:4][0] = 400 | |
assert row[1:4]['counts'] == 400 | |
row[1:4]['counts'] = 300 | |
assert row[1:4]['counts'] == 300 | |
# Test stepping for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/59 | |
row[1:4][::-1][-1] = 500 | |
assert row[1:4]['counts'] == 500 | |
row[1:4:2][0] = 300 | |
assert row[1:4]['counts'] == 300 | |
pytest.raises(KeyError, lambda r: r[1:4]['flag'], row) | |
assert row[1:4].field(0) == 300 | |
assert row[1:4].field('counts') == 300 | |
pytest.raises(KeyError, row[1:4].field, 'flag') | |
row[1:4].setfield('counts', 500) | |
assert row[1:4].field(0) == 500 | |
pytest.raises(KeyError, row[1:4].setfield, 'flag', False) | |
assert t1[1].data._coldefs._arrays[1][2] == 500 | |
assert t1[1].data._coldefs.columns[1].array[2] == 500 | |
assert t1[1].columns._arrays[1][2] == 500 | |
assert t1[1].columns.columns[1].array[2] == 500 | |
assert t1[1].data[2][1] == 500 | |
> t1.close() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:927: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ TestTableFunctions.test_fits_record_len ____________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x00000000187bf328> | |
def test_fits_record_len(self): | |
counts = np.array([312, 334, 308, 317]) | |
names = np.array(['NGC1', 'NGC2', 'NGC3', 'NCG4']) | |
c1 = fits.Column(name='target', format='10A', array=names) | |
c2 = fits.Column(name='counts', format='J', unit='DN', array=counts) | |
c3 = fits.Column(name='notes', format='A10') | |
c4 = fits.Column(name='spectrum', format='5E') | |
c5 = fits.Column(name='flag', format='L', array=[1, 0, 1, 1]) | |
coldefs = fits.ColDefs([c1, c2, c3, c4, c5]) | |
tbhdu = fits.BinTableHDU.from_columns(coldefs) | |
tbhdu.writeto(self.temp('table1.fits')) | |
t1 = fits.open(self.temp('table1.fits')) | |
assert len(t1[1].data[0]) == 5 | |
assert len(t1[1].data[0][0:4]) == 4 | |
assert len(t1[1].data[0][0:5]) == 5 | |
assert len(t1[1].data[0][0:6]) == 5 | |
assert len(t1[1].data[0][0:7]) == 5 | |
assert len(t1[1].data[0][1:4]) == 3 | |
assert len(t1[1].data[0][1:5]) == 4 | |
assert len(t1[1].data[0][1:6]) == 4 | |
assert len(t1[1].data[0][1:7]) == 4 | |
> t1.close() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:953: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________ TestTableFunctions.test_verify_data_references ________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000001a397f68> | |
def test_verify_data_references(self): | |
counts = np.array([312, 334, 308, 317]) | |
names = np.array(['NGC1', 'NGC2', 'NGC3', 'NCG4']) | |
c1 = fits.Column(name='target', format='10A', array=names) | |
c2 = fits.Column(name='counts', format='J', unit='DN', array=counts) | |
c3 = fits.Column(name='notes', format='A10') | |
c4 = fits.Column(name='spectrum', format='5E') | |
c5 = fits.Column(name='flag', format='L', array=[1, 0, 1, 1]) | |
coldefs = fits.ColDefs([c1, c2, c3, c4, c5]) | |
tbhdu = fits.BinTableHDU.from_columns(coldefs) | |
# Verify that original ColDefs object has independent Column | |
# objects. | |
assert id(coldefs.columns[0]) != id(c1) | |
# Verify that original ColDefs object has independent ndarray | |
# objects. | |
assert id(coldefs.columns[0].array) != id(names) | |
# Verify that original ColDefs object references the same data | |
# object as the original Column object. | |
assert id(coldefs.columns[0].array) == id(c1.array) | |
assert id(coldefs.columns[0].array) == id(coldefs._arrays[0]) | |
# Verify new HDU has an independent ColDefs object. | |
assert id(coldefs) != id(tbhdu.columns) | |
# Verify new HDU has independent Column objects. | |
assert id(coldefs.columns[0]) != id(tbhdu.columns.columns[0]) | |
# Verify new HDU has independent ndarray objects. | |
assert (id(coldefs.columns[0].array) != | |
id(tbhdu.columns.columns[0].array)) | |
# Verify that both ColDefs objects in the HDU reference the same | |
# Coldefs object. | |
assert id(tbhdu.columns) == id(tbhdu.data._coldefs) | |
# Verify that all ndarray objects within the HDU reference the | |
# same ndarray. | |
assert (id(tbhdu.data._coldefs.columns[0].array) == | |
id(tbhdu.data._coldefs._arrays[0])) | |
assert (id(tbhdu.data._coldefs.columns[0].array) == | |
id(tbhdu.columns.columns[0].array)) | |
assert (id(tbhdu.data._coldefs.columns[0].array) == | |
id(tbhdu.columns._arrays[0])) | |
tbhdu.writeto(self.temp('table1.fits')) | |
t1 = fits.open(self.temp('table1.fits')) | |
t1[1].data[0][1] = 213 | |
assert t1[1].data[0][1] == 213 | |
assert t1[1].data._coldefs._arrays[1][0] == 213 | |
assert t1[1].data._coldefs.columns[1].array[0] == 213 | |
assert t1[1].columns._arrays[1][0] == 213 | |
assert t1[1].columns.columns[1].array[0] == 213 | |
t1[1].data._coldefs._arrays[1][0] = 100 | |
assert t1[1].data[0][1] == 100 | |
assert t1[1].data._coldefs._arrays[1][0] == 100 | |
assert t1[1].data._coldefs.columns[1].array[0] == 100 | |
assert t1[1].columns._arrays[1][0] == 100 | |
assert t1[1].columns.columns[1].array[0] == 100 | |
t1[1].data._coldefs.columns[1].array[0] = 500 | |
assert t1[1].data[0][1] == 500 | |
assert t1[1].data._coldefs._arrays[1][0] == 500 | |
assert t1[1].data._coldefs.columns[1].array[0] == 500 | |
assert t1[1].columns._arrays[1][0] == 500 | |
assert t1[1].columns.columns[1].array[0] == 500 | |
t1[1].columns._arrays[1][0] = 600 | |
assert t1[1].data[0][1] == 600 | |
assert t1[1].data._coldefs._arrays[1][0] == 600 | |
assert t1[1].data._coldefs.columns[1].array[0] == 600 | |
assert t1[1].columns._arrays[1][0] == 600 | |
assert t1[1].columns.columns[1].array[0] == 600 | |
t1[1].columns.columns[1].array[0] = 800 | |
assert t1[1].data[0][1] == 800 | |
assert t1[1].data._coldefs._arrays[1][0] == 800 | |
assert t1[1].data._coldefs.columns[1].array[0] == 800 | |
assert t1[1].columns._arrays[1][0] == 800 | |
assert t1[1].columns.columns[1].array[0] == 800 | |
> t1.close() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:1178: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________ TestTableFunctions.test_new_table_with_ndarray ________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000000f156cd0> | |
def test_new_table_with_ndarray(self): | |
counts = np.array([312, 334, 308, 317]) | |
names = np.array(['NGC1', 'NGC2', 'NGC3', 'NCG4']) | |
c1 = fits.Column(name='target', format='10A', array=names) | |
c2 = fits.Column(name='counts', format='J', unit='DN', array=counts) | |
c3 = fits.Column(name='notes', format='A10') | |
c4 = fits.Column(name='spectrum', format='5E') | |
c5 = fits.Column(name='flag', format='L', array=[1, 0, 1, 1]) | |
coldefs = fits.ColDefs([c1, c2, c3, c4, c5]) | |
tbhdu = fits.BinTableHDU.from_columns(coldefs) | |
tbhdu1 = fits.BinTableHDU.from_columns(tbhdu.data.view(np.ndarray)) | |
# Verify that all ndarray objects within the HDU reference the | |
# same ndarray. | |
assert (id(tbhdu1.data._coldefs.columns[0].array) == | |
id(tbhdu1.data._coldefs._arrays[0])) | |
assert (id(tbhdu1.data._coldefs.columns[0].array) == | |
id(tbhdu1.columns.columns[0].array)) | |
assert (id(tbhdu1.data._coldefs.columns[0].array) == | |
id(tbhdu1.columns._arrays[0])) | |
# Ensure I can change the value of one data element and it effects | |
# all of the others. | |
tbhdu1.data[0][1] = 213 | |
assert tbhdu1.data[0][1] == 213 | |
assert tbhdu1.data._coldefs._arrays[1][0] == 213 | |
assert tbhdu1.data._coldefs.columns[1].array[0] == 213 | |
assert tbhdu1.columns._arrays[1][0] == 213 | |
assert tbhdu1.columns.columns[1].array[0] == 213 | |
tbhdu1.data._coldefs._arrays[1][0] = 100 | |
assert tbhdu1.data[0][1] == 100 | |
assert tbhdu1.data._coldefs._arrays[1][0] == 100 | |
assert tbhdu1.data._coldefs.columns[1].array[0] == 100 | |
assert tbhdu1.columns._arrays[1][0] == 100 | |
assert tbhdu1.columns.columns[1].array[0] == 100 | |
tbhdu1.data._coldefs.columns[1].array[0] = 500 | |
assert tbhdu1.data[0][1] == 500 | |
assert tbhdu1.data._coldefs._arrays[1][0] == 500 | |
assert tbhdu1.data._coldefs.columns[1].array[0] == 500 | |
assert tbhdu1.columns._arrays[1][0] == 500 | |
assert tbhdu1.columns.columns[1].array[0] == 500 | |
tbhdu1.columns._arrays[1][0] = 600 | |
assert tbhdu1.data[0][1] == 600 | |
assert tbhdu1.data._coldefs._arrays[1][0] == 600 | |
assert tbhdu1.data._coldefs.columns[1].array[0] == 600 | |
assert tbhdu1.columns._arrays[1][0] == 600 | |
assert tbhdu1.columns.columns[1].array[0] == 600 | |
tbhdu1.columns.columns[1].array[0] = 800 | |
assert tbhdu1.data[0][1] == 800 | |
assert tbhdu1.data._coldefs._arrays[1][0] == 800 | |
assert tbhdu1.data._coldefs.columns[1].array[0] == 800 | |
assert tbhdu1.columns._arrays[1][0] == 800 | |
assert tbhdu1.columns.columns[1].array[0] == 800 | |
tbhdu1.writeto(self.temp('table1.fits')) | |
t1 = fits.open(self.temp('table1.fits')) | |
t1[1].data[0][1] = 213 | |
assert t1[1].data[0][1] == 213 | |
assert t1[1].data._coldefs._arrays[1][0] == 213 | |
assert t1[1].data._coldefs.columns[1].array[0] == 213 | |
assert t1[1].columns._arrays[1][0] == 213 | |
assert t1[1].columns.columns[1].array[0] == 213 | |
t1[1].data._coldefs._arrays[1][0] = 100 | |
assert t1[1].data[0][1] == 100 | |
assert t1[1].data._coldefs._arrays[1][0] == 100 | |
assert t1[1].data._coldefs.columns[1].array[0] == 100 | |
assert t1[1].columns._arrays[1][0] == 100 | |
assert t1[1].columns.columns[1].array[0] == 100 | |
t1[1].data._coldefs.columns[1].array[0] = 500 | |
assert t1[1].data[0][1] == 500 | |
assert t1[1].data._coldefs._arrays[1][0] == 500 | |
assert t1[1].data._coldefs.columns[1].array[0] == 500 | |
assert t1[1].columns._arrays[1][0] == 500 | |
assert t1[1].columns.columns[1].array[0] == 500 | |
t1[1].columns._arrays[1][0] = 600 | |
assert t1[1].data[0][1] == 600 | |
assert t1[1].data._coldefs._arrays[1][0] == 600 | |
assert t1[1].data._coldefs.columns[1].array[0] == 600 | |
assert t1[1].columns._arrays[1][0] == 600 | |
assert t1[1].columns.columns[1].array[0] == 600 | |
t1[1].columns.columns[1].array[0] = 800 | |
assert t1[1].data[0][1] == 800 | |
assert t1[1].data._coldefs._arrays[1][0] == 800 | |
assert t1[1].data._coldefs.columns[1].array[0] == 800 | |
assert t1[1].columns._arrays[1][0] == 800 | |
assert t1[1].columns.columns[1].array[0] == 800 | |
> t1.close() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:1283: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________ TestTableFunctions.test_new_table_with_fits_rec ________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000000cb2b558> | |
def test_new_table_with_fits_rec(self): | |
counts = np.array([312, 334, 308, 317]) | |
names = np.array(['NGC1', 'NGC2', 'NGC3', 'NCG4']) | |
c1 = fits.Column(name='target', format='10A', array=names) | |
c2 = fits.Column(name='counts', format='J', unit='DN', array=counts) | |
c3 = fits.Column(name='notes', format='A10') | |
c4 = fits.Column(name='spectrum', format='5E') | |
c5 = fits.Column(name='flag', format='L', array=[1, 0, 1, 1]) | |
coldefs = fits.ColDefs([c1, c2, c3, c4, c5]) | |
tbhdu = fits.BinTableHDU.from_columns(coldefs) | |
tbhdu.data[0][1] = 213 | |
assert tbhdu.data[0][1] == 213 | |
assert tbhdu.data._coldefs._arrays[1][0] == 213 | |
assert tbhdu.data._coldefs.columns[1].array[0] == 213 | |
assert tbhdu.columns._arrays[1][0] == 213 | |
assert tbhdu.columns.columns[1].array[0] == 213 | |
tbhdu.data._coldefs._arrays[1][0] = 100 | |
assert tbhdu.data[0][1] == 100 | |
assert tbhdu.data._coldefs._arrays[1][0] == 100 | |
assert tbhdu.data._coldefs.columns[1].array[0] == 100 | |
assert tbhdu.columns._arrays[1][0] == 100 | |
assert tbhdu.columns.columns[1].array[0] == 100 | |
tbhdu.data._coldefs.columns[1].array[0] = 500 | |
assert tbhdu.data[0][1] == 500 | |
assert tbhdu.data._coldefs._arrays[1][0] == 500 | |
assert tbhdu.data._coldefs.columns[1].array[0] == 500 | |
assert tbhdu.columns._arrays[1][0] == 500 | |
assert tbhdu.columns.columns[1].array[0] == 500 | |
tbhdu.columns._arrays[1][0] = 600 | |
assert tbhdu.data[0][1] == 600 | |
assert tbhdu.data._coldefs._arrays[1][0] == 600 | |
assert tbhdu.data._coldefs.columns[1].array[0] == 600 | |
assert tbhdu.columns._arrays[1][0] == 600 | |
assert tbhdu.columns.columns[1].array[0] == 600 | |
tbhdu.columns.columns[1].array[0] = 800 | |
assert tbhdu.data[0][1] == 800 | |
assert tbhdu.data._coldefs._arrays[1][0] == 800 | |
assert tbhdu.data._coldefs.columns[1].array[0] == 800 | |
assert tbhdu.columns._arrays[1][0] == 800 | |
assert tbhdu.columns.columns[1].array[0] == 800 | |
tbhdu.columns.columns[1].array[0] = 312 | |
tbhdu.writeto(self.temp('table1.fits')) | |
t1 = fits.open(self.temp('table1.fits')) | |
t1[1].data[0][1] = 1 | |
fr = t1[1].data | |
assert t1[1].data[0][1] == 1 | |
assert t1[1].data._coldefs._arrays[1][0] == 1 | |
assert t1[1].data._coldefs.columns[1].array[0] == 1 | |
assert t1[1].columns._arrays[1][0] == 1 | |
assert t1[1].columns.columns[1].array[0] == 1 | |
assert fr[0][1] == 1 | |
assert fr._coldefs._arrays[1][0] == 1 | |
assert fr._coldefs.columns[1].array[0] == 1 | |
fr._coldefs.columns[1].array[0] = 312 | |
tbhdu1 = fits.BinTableHDU.from_columns(fr) | |
i = 0 | |
for row in tbhdu1.data: | |
for j in range(len(row)): | |
if isinstance(row[j], np.ndarray): | |
assert (row[j] == tbhdu.data[i][j]).all() | |
else: | |
assert row[j] == tbhdu.data[i][j] | |
i = i + 1 | |
tbhdu1.data[0][1] = 213 | |
assert t1[1].data[0][1] == 312 | |
assert t1[1].data._coldefs._arrays[1][0] == 312 | |
assert t1[1].data._coldefs.columns[1].array[0] == 312 | |
assert t1[1].columns._arrays[1][0] == 312 | |
assert t1[1].columns.columns[1].array[0] == 312 | |
assert fr[0][1] == 312 | |
assert fr._coldefs._arrays[1][0] == 312 | |
assert fr._coldefs.columns[1].array[0] == 312 | |
assert tbhdu1.data[0][1] == 213 | |
assert tbhdu1.data._coldefs._arrays[1][0] == 213 | |
assert tbhdu1.data._coldefs.columns[1].array[0] == 213 | |
assert tbhdu1.columns._arrays[1][0] == 213 | |
assert tbhdu1.columns.columns[1].array[0] == 213 | |
t1[1].data[0][1] = 10 | |
assert t1[1].data[0][1] == 10 | |
assert t1[1].data._coldefs._arrays[1][0] == 10 | |
assert t1[1].data._coldefs.columns[1].array[0] == 10 | |
assert t1[1].columns._arrays[1][0] == 10 | |
assert t1[1].columns.columns[1].array[0] == 10 | |
assert fr[0][1] == 10 | |
assert fr._coldefs._arrays[1][0] == 10 | |
assert fr._coldefs.columns[1].array[0] == 10 | |
assert tbhdu1.data[0][1] == 213 | |
assert tbhdu1.data._coldefs._arrays[1][0] == 213 | |
assert tbhdu1.data._coldefs.columns[1].array[0] == 213 | |
assert tbhdu1.columns._arrays[1][0] == 213 | |
assert tbhdu1.columns.columns[1].array[0] == 213 | |
tbhdu1.data._coldefs._arrays[1][0] = 666 | |
assert t1[1].data[0][1] == 10 | |
assert t1[1].data._coldefs._arrays[1][0] == 10 | |
assert t1[1].data._coldefs.columns[1].array[0] == 10 | |
assert t1[1].columns._arrays[1][0] == 10 | |
assert t1[1].columns.columns[1].array[0] == 10 | |
assert fr[0][1] == 10 | |
assert fr._coldefs._arrays[1][0] == 10 | |
assert fr._coldefs.columns[1].array[0] == 10 | |
assert tbhdu1.data[0][1] == 666 | |
assert tbhdu1.data._coldefs._arrays[1][0] == 666 | |
assert tbhdu1.data._coldefs.columns[1].array[0] == 666 | |
assert tbhdu1.columns._arrays[1][0] == 666 | |
assert tbhdu1.columns.columns[1].array[0] == 666 | |
> t1.close() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:1412: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________ TestTableFunctions.test_fits_rec_column_access ________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x0000000016b188e0> | |
def test_fits_rec_column_access(self): | |
t = fits.open(self.data('table.fits')) | |
tbdata = t[1].data | |
assert (tbdata.V_mag == tbdata.field('V_mag')).all() | |
assert (tbdata.V_mag == tbdata['V_mag']).all() | |
> t.close() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:1592: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________ TestTableFunctions.test_table_with_zero_width_column _____________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x00000000129c23a0> | |
def test_table_with_zero_width_column(self): | |
hdul = fits.open(self.data('zerowidth.fits')) | |
tbhdu = hdul[2] # This HDU contains a zero-width column 'ORBPARM' | |
assert 'ORBPARM' in tbhdu.columns.names | |
# The ORBPARM column should not be in the data, though the data should | |
# be readable | |
assert 'ORBPARM' in tbhdu.data.names | |
assert 'ORBPARM' in tbhdu.data.dtype.names | |
# Verify that some of the data columns are still correctly accessible | |
# by name | |
assert tbhdu.data[0]['ANNAME'] == 'VLA:_W16' | |
assert comparefloats( | |
tbhdu.data[0]['STABXYZ'], | |
np.array([499.85566663, -1317.99231554, -735.18866164], | |
dtype=np.float64)) | |
assert tbhdu.data[0]['NOSTA'] == 1 | |
assert tbhdu.data[0]['MNTSTA'] == 0 | |
assert tbhdu.data[-1]['ANNAME'] == 'VPT:_OUT' | |
assert comparefloats( | |
tbhdu.data[-1]['STABXYZ'], | |
np.array([0.0, 0.0, 0.0], dtype=np.float64)) | |
assert tbhdu.data[-1]['NOSTA'] == 29 | |
assert tbhdu.data[-1]['MNTSTA'] == 0 | |
hdul.writeto(self.temp('newtable.fits')) | |
> hdul.close() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:1618: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________ TestTableFunctions.test_string_column_padding _________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x0000000022026838> | |
def test_string_column_padding(self): | |
a = ['img1', 'img2', 'img3a', 'p'] | |
s = 'img1\x00\x00\x00\x00\x00\x00' \ | |
'img2\x00\x00\x00\x00\x00\x00' \ | |
'img3a\x00\x00\x00\x00\x00' \ | |
'p\x00\x00\x00\x00\x00\x00\x00\x00\x00' | |
acol = fits.Column(name='MEMNAME', format='A10', | |
array=chararray.array(a)) | |
ahdu = fits.BinTableHDU.from_columns([acol]) | |
assert ahdu.data.tostring().decode('raw-unicode-escape') == s | |
ahdu.writeto(self.temp('newtable.fits')) | |
with fits.open(self.temp('newtable.fits')) as hdul: | |
assert hdul[1].data.tostring().decode('raw-unicode-escape') == s | |
> assert (hdul[1].data['MEMNAME'] == a).all() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:1655: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________ TestTableFunctions.test_multi_dimensional_columns _______________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x0000000010e9b910> | |
def test_multi_dimensional_columns(self): | |
""" | |
Tests the multidimensional column implementation with both numeric | |
arrays and string arrays. | |
""" | |
data = np.rec.array( | |
[([0, 1, 2, 3, 4, 5], 'row1' * 2), | |
([6, 7, 8, 9, 0, 1], 'row2' * 2), | |
([2, 3, 4, 5, 6, 7], 'row3' * 2)], formats='6i4,a8') | |
thdu = fits.BinTableHDU.from_columns(data) | |
# Modify the TDIM fields to my own specification | |
thdu.header['TDIM1'] = '(2,3)' | |
thdu.header['TDIM2'] = '(4,2)' | |
thdu.writeto(self.temp('newtable.fits')) | |
with fits.open(self.temp('newtable.fits')) as hdul: | |
thdu = hdul[1] | |
c1 = thdu.data.field(0) | |
c2 = thdu.data.field(1) | |
assert c1.shape == (3, 3, 2) | |
assert c2.shape == (3, 2) | |
assert (c1 == np.array([[[0, 1], [2, 3], [4, 5]], | |
[[6, 7], [8, 9], [0, 1]], | |
[[2, 3], [4, 5], [6, 7]]])).all() | |
> assert (c2 == np.array([['row1', 'row1'], | |
['row2', 'row2'], | |
['row3', 'row3']])).all() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:1705: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______ TestTableFunctions.test_bin_table_init_from_string_array_column ________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x0000000022caa5d0> | |
def test_bin_table_init_from_string_array_column(self): | |
""" | |
Tests two ways of creating a new `BinTableHDU` from a column of | |
string arrays. | |
This tests for a couple different regressions, and ensures that | |
both BinTableHDU(data=arr) and BinTableHDU.from_columns(arr) work | |
equivalently. | |
Some of this is redundant with the following test, but checks some | |
subtly different cases. | |
""" | |
data = [[b'abcd', b'efgh'], | |
[b'ijkl', b'mnop'], | |
[b'qrst', b'uvwx']] | |
arr = np.array([(data,), (data,), (data,), (data,), (data,)], | |
dtype=[('S', '(3, 2)S4')]) | |
with catch_warnings() as w: | |
tbhdu1 = fits.BinTableHDU(data=arr) | |
assert len(w) == 0 | |
def test_dims_and_roundtrip(tbhdu): | |
assert tbhdu.data['S'].shape == (5, 3, 2) | |
assert tbhdu.data['S'].dtype.str.endswith('U4') | |
tbhdu.writeto(self.temp('test.fits'), overwrite=True) | |
with fits.open(self.temp('test.fits')) as hdul: | |
tbhdu2 = hdul[1] | |
assert tbhdu2.header['TDIM1'] == '(4,2,3)' | |
assert tbhdu2.data['S'].shape == (5, 3, 2) | |
assert tbhdu.data['S'].dtype.str.endswith('U4') | |
assert np.all(tbhdu2.data['S'] == tbhdu.data['S']) | |
> test_dims_and_roundtrip(tbhdu1) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:1779: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:1777: in test_dims_and_roundtrip | |
assert np.all(tbhdu2.data['S'] == tbhdu.data['S']) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________ TestTableFunctions.test_columns_with_truncating_tdim _____________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000001b68b3d0> | |
def test_columns_with_truncating_tdim(self): | |
""" | |
According to the FITS standard (section 7.3.2): | |
If the number of elements in the array implied by the TDIMn is less | |
than the allocated size of the ar- ray in the FITS file, then the | |
unused trailing elements should be interpreted as containing | |
undefined fill values. | |
*deep sigh* What this means is if a column has a repeat count larger | |
than the number of elements indicated by its TDIM (ex: TDIM1 = '(2,2)', | |
but TFORM1 = 6I), then instead of this being an outright error we are | |
to take the first 4 elements as implied by the TDIM and ignore the | |
additional two trailing elements. | |
""" | |
# It's hard to even successfully create a table like this. I think | |
# it *should* be difficult, but once created it should at least be | |
# possible to read. | |
arr1 = [[b'ab', b'cd'], [b'ef', b'gh'], [b'ij', b'kl']] | |
arr2 = [1, 2, 3, 4, 5] | |
arr = np.array([(arr1, arr2), (arr1, arr2)], | |
dtype=[('a', '(3, 2)S2'), ('b', '5i8')]) | |
tbhdu = fits.BinTableHDU(data=arr) | |
tbhdu.writeto(self.temp('test.fits')) | |
with open(self.temp('test.fits'), 'rb') as f: | |
raw_bytes = f.read() | |
# Artificially truncate TDIM in the header; this seems to be the | |
# easiest way to do this while getting around Astropy's insistence on the | |
# data and header matching perfectly; again, we have no interest in | |
# making it possible to write files in this format, only read them | |
with open(self.temp('test.fits'), 'wb') as f: | |
f.write(raw_bytes.replace(b'(2,2,3)', b'(2,2,2)')) | |
with fits.open(self.temp('test.fits')) as hdul: | |
tbhdu2 = hdul[1] | |
assert tbhdu2.header['TDIM1'] == '(2,2,2)' | |
assert tbhdu2.header['TFORM1'] == '12A' | |
for row in tbhdu2.data: | |
assert np.all(row['a'] == [['ab', 'cd'], ['ef', 'gh']]) | |
> assert np.all(row['b'] == [1, 2, 3, 4, 5]) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:1828: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________ TestTableFunctions.test_string_array_round_trip ________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x0000000022400f38> | |
def test_string_array_round_trip(self): | |
"""Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/201""" | |
data = [['abc', 'def', 'ghi'], | |
['jkl', 'mno', 'pqr'], | |
['stu', 'vwx', 'yz ']] | |
recarr = np.rec.array([(data,), (data,)], formats=['(3,3)S3']) | |
t = fits.BinTableHDU(data=recarr) | |
t.writeto(self.temp('test.fits')) | |
with fits.open(self.temp('test.fits')) as h: | |
assert 'TDIM1' in h[1].header | |
assert h[1].header['TDIM1'] == '(3,3,3)' | |
assert len(h[1].data) == 2 | |
assert len(h[1].data[0]) == 1 | |
> assert (h[1].data.field(0)[0] == | |
np.char.decode(recarr.field(0)[0], 'ascii')).all() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:1847: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________ TestTableFunctions.test_new_table_with_nd_column _______________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000000e107a60> | |
def test_new_table_with_nd_column(self): | |
"""Regression test for | |
https://github.com/spacetelescope/PyFITS/issues/3 | |
""" | |
arra = np.array(['a', 'b'], dtype='|S1') | |
arrb = np.array([['a', 'bc'], ['cd', 'e']], dtype='|S2') | |
arrc = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]) | |
cols = [ | |
fits.Column(name='str', format='1A', array=arra), | |
fits.Column(name='strarray', format='4A', dim='(2,2)', | |
array=arrb), | |
fits.Column(name='intarray', format='4I', dim='(2, 2)', | |
array=arrc) | |
] | |
hdu = fits.BinTableHDU.from_columns(fits.ColDefs(cols)) | |
hdu.writeto(self.temp('test.fits')) | |
with fits.open(self.temp('test.fits')) as h: | |
# Need to force string arrays to byte arrays in order to compare | |
# correctly on Python 3 | |
assert (h[1].data['str'].encode('ascii') == arra).all() | |
assert (h[1].data['strarray'].encode('ascii') == arrb).all() | |
> assert (h[1].data['intarray'] == arrc).all() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:1889: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________ TestTableFunctions.test_mismatched_tform_and_tdim _______________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000000cd155c8> | |
def test_mismatched_tform_and_tdim(self): | |
"""Normally the product of the dimensions listed in a TDIMn keyword | |
must be less than or equal to the repeat count in the TFORMn keyword. | |
This tests that this works if less than (treating the trailing bytes | |
as unspecified fill values per the FITS standard) and fails if the | |
dimensions specified by TDIMn are greater than the repeat count. | |
""" | |
arra = np.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]) | |
arrb = np.array([[[9, 10], [11, 12]], [[13, 14], [15, 16]]]) | |
cols = [fits.Column(name='a', format='20I', dim='(2,2)', | |
array=arra), | |
fits.Column(name='b', format='4I', dim='(2,2)', | |
array=arrb)] | |
# The first column has the mismatched repeat count | |
hdu = fits.BinTableHDU.from_columns(fits.ColDefs(cols)) | |
hdu.writeto(self.temp('test.fits')) | |
with fits.open(self.temp('test.fits')) as h: | |
assert h[1].header['TFORM1'] == '20I' | |
assert h[1].header['TFORM2'] == '4I' | |
assert h[1].header['TDIM1'] == h[1].header['TDIM2'] == '(2,2)' | |
assert (h[1].data['a'] == arra).all() | |
assert (h[1].data['b'] == arrb).all() | |
> assert h[1].data.itemsize == 48 # 16-bits times 24 | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:1918: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ TestTableFunctions.test_tdim_of_size_one ___________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x0000000016b18988> | |
def test_tdim_of_size_one(self): | |
"""Regression test for https://github.com/astropy/astropy/pull/3580""" | |
with fits.open(self.data('tdim.fits')) as hdulist: | |
> assert hdulist[1].data['V_mag'].shape == (3, 1, 1) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:1929: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________________ TestTableFunctions.test_slicing ________________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x00000000133d0100> | |
def test_slicing(self): | |
"""Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/52""" | |
with fits.open(self.data('table.fits')) as f: | |
> data = f[1].data | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:1935: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________________ TestTableFunctions.test_array_slicing _____________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x00000000220682c0> | |
def test_array_slicing(self): | |
"""Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/55""" | |
with fits.open(self.data('table.fits')) as f: | |
> data = f[1].data | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:1953: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________________ TestTableFunctions.test_array_broadcasting __________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000001849a218> | |
def test_array_broadcasting(self): | |
""" | |
Regression test for https://github.com/spacetelescope/PyFITS/pull/48 | |
""" | |
with fits.open(self.data('table.fits')) as hdu: | |
data = hdu[1].data | |
data['V_mag'] = 0 | |
assert np.all(data['V_mag'] == 0) | |
data['V_mag'] = 1 | |
assert np.all(data['V_mag'] == 1) | |
for container in (list, tuple, np.array): | |
data['V_mag'] = container([1, 2, 3]) | |
> assert np.array_equal(data['V_mag'], np.array([1, 2, 3])) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:1980: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________ TestTableFunctions.test_array_slicing_readonly ________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000002239b520> | |
def test_array_slicing_readonly(self): | |
""" | |
Like test_array_slicing but with the file opened in 'readonly' mode. | |
Regression test for a crash when slicing readonly memmap'd tables. | |
""" | |
with fits.open(self.data('table.fits'), mode='readonly') as f: | |
> data = f[1].data | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:1989: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________ TestTableFunctions.test_dump_load_round_trip _________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x0000000021646a68> | |
def test_dump_load_round_trip(self): | |
""" | |
A simple test of the dump/load methods; dump the data, column, and | |
header files and try to reload the table from them. | |
""" | |
hdul = fits.open(self.data('table.fits')) | |
tbhdu = hdul[1] | |
datafile = self.temp('data.txt') | |
cdfile = self.temp('coldefs.txt') | |
hfile = self.temp('header.txt') | |
tbhdu.dump(datafile, cdfile, hfile) | |
new_tbhdu = fits.BinTableHDU.load(datafile, cdfile, hfile) | |
assert comparerecords(tbhdu.data, new_tbhdu.data) | |
# Double check that the headers are equivalent | |
assert str(tbhdu.header) == str(new_tbhdu.header) | |
> hdul.close() | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2021: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________ TestTableFunctions.test_table_from_bool_fields ________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x0000000016d3cf00> | |
def test_table_from_bool_fields(self): | |
""" | |
Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/113 | |
Tests creating a table from a recarray containing numpy.bool columns. | |
""" | |
array = np.rec.array([(True, False), (False, True)], formats='|b1,|b1') | |
thdu = fits.BinTableHDU.from_columns(array) | |
assert thdu.columns.formats == ['L', 'L'] | |
assert comparerecords(thdu.data, array) | |
# Test round trip | |
thdu.writeto(self.temp('table.fits')) | |
> data = fits.getdata(self.temp('table.fits'), ext=1) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2125: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/convenience.py:204: in getdata | |
hdulist.close(closed=closed) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________________ TestTableFunctions.test_bool_column_update __________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000000f149ad0> | |
def test_bool_column_update(self): | |
"""Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/139""" | |
c1 = fits.Column('F1', 'L', array=[True, False]) | |
c2 = fits.Column('F2', 'L', array=[False, True]) | |
thdu = fits.BinTableHDU.from_columns(fits.ColDefs([c1, c2])) | |
thdu.writeto(self.temp('table.fits')) | |
with fits.open(self.temp('table.fits'), mode='update') as hdul: | |
hdul[1].data['F1'][1] = True | |
> hdul[1].data['F2'][0] = True | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2151: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________________ TestTableFunctions.test_missing_tnull _____________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000000c8b4b80> | |
def test_missing_tnull(self): | |
"""Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/197""" | |
c = fits.Column('F1', 'A3', null='---', | |
array=np.array(['1.0', '2.0', '---', '3.0']), | |
ascii=True) | |
table = fits.TableHDU.from_columns([c]) | |
table.writeto(self.temp('test.fits')) | |
# Now let's delete the TNULL1 keyword, making this essentially | |
# unreadable | |
with fits.open(self.temp('test.fits'), mode='update') as h: | |
h[1].header['TFORM1'] = 'E3' | |
del h[1].header['TNULL1'] | |
with fits.open(self.temp('test.fits')) as h: | |
> pytest.raises(ValueError, lambda: h[1].data['F1']) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2173: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ TestTableFunctions.test_blank_field_zero ___________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x0000000012a7d910> | |
def test_blank_field_zero(self): | |
"""Regression test for https://github.com/astropy/astropy/issues/5134 | |
Blank values in numerical columns of ASCII tables should be replaced | |
with zeros, so they can be loaded into numpy arrays. | |
When a TNULL value is set and there are blank fields not equal to that | |
value, they should be replaced with zeros. | |
""" | |
# Test an integer column with blank string as null | |
nullval1 = ' ' | |
c1 = fits.Column('F1', format='I8', null=nullval1, | |
array=np.array([0, 1, 2, 3, 4]), | |
ascii=True) | |
table = fits.TableHDU.from_columns([c1]) | |
table.writeto(self.temp('ascii_null.fits')) | |
# Replace the 1st col, 3rd row, with a null field. | |
with open(self.temp('ascii_null.fits'), mode='r+') as h: | |
nulled = h.read().replace('2 ', ' ') | |
h.seek(0) | |
h.write(nulled) | |
with fits.open(self.temp('ascii_null.fits'), memmap=True) as f: | |
> assert f[1].data[2][0] == 0 | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2209: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________________ TestTableFunctions.test_table_none ______________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x00000000161ee800> | |
def test_table_none(self): | |
"""Regression test | |
for https://github.com/spacetelescope/PyFITS/issues/27 | |
""" | |
with fits.open(self.data('tb.fits')) as h: | |
h[1].data | |
h[1].data = None | |
assert isinstance(h[1].data, fits.FITS_rec) | |
assert len(h[1].data) == 0 | |
> h[1].writeto(self.temp('test.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2247: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________ TestTableFunctions.test_unncessary_table_load _________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x00000000124a2b48> | |
def test_unncessary_table_load(self): | |
"""Test unnecessary parsing and processing of FITS tables when writing | |
direclty from one FITS file to a new file without first reading the | |
data for user manipulation. | |
In other words, it should be possible to do a direct copy of the raw | |
data without unecessary processing of the data. | |
""" | |
with fits.open(self.data('table.fits')) as h: | |
> h[1].writeto(self.temp('test.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2266: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________ TestTableFunctions.test_table_from_columns_of_other_table ___________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x0000000019c87788> | |
def test_table_from_columns_of_other_table(self): | |
"""Tests a rare corner case where the columns of an existing table | |
are used to create a new table with the new_table function. In this | |
specific case, however, the existing table's data has not been read | |
yet, so new_table has to get at it through the Delayed proxy. | |
Note: Although this previously tested new_table it now uses | |
BinTableHDU.from_columns directly, around which new_table is a mere | |
wrapper. | |
""" | |
hdul = fits.open(self.data('table.fits')) | |
# Make sure the column array is in fact delayed... | |
assert isinstance(hdul[1].columns._arrays[0], Delayed) | |
# Create a new table... | |
t = fits.BinTableHDU.from_columns(hdul[1].columns) | |
# The original columns should no longer be delayed... | |
assert not isinstance(hdul[1].columns._arrays[0], Delayed) | |
t.writeto(self.temp('test.fits')) | |
with fits.open(self.temp('test.fits')) as hdul2: | |
> assert comparerecords(hdul[1].data, hdul2[1].data) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2302: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________ TestTableFunctions.test_bintable_to_asciitable ________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x0000000021e86448> | |
def test_bintable_to_asciitable(self): | |
"""Tests initializing a TableHDU with the data from a BinTableHDU.""" | |
with fits.open(self.data('tb.fits')) as hdul: | |
tbdata = hdul[1].data | |
tbhdu = fits.TableHDU(data=tbdata) | |
with ignore_warnings(): | |
tbhdu.writeto(self.temp('test.fits'), overwrite=True) | |
with fits.open(self.temp('test.fits')) as hdul2: | |
tbdata2 = hdul2[1].data | |
assert np.all(tbdata['c1'] == tbdata2['c1']) | |
assert np.all(tbdata['c2'] == tbdata2['c2']) | |
# c3 gets converted from float32 to float64 when writing | |
# test.fits, so cast to float32 before testing that the correct | |
# value is retrieved | |
assert np.all(tbdata['c3'].astype(np.float32) == | |
tbdata2['c3'].astype(np.float32)) | |
# c4 is a boolean column in the original table; we want ASCII | |
# columns to convert these to columns of 'T'/'F' strings | |
> assert np.all(np.where(tbdata['c4'], 'T', 'F') == | |
tbdata2['c4']) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2325: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000021ed3fa0>, <astropy.io.fits.hdu.table.TableHDU object at 0x0000000021ed3440>] | |
type = None, value = None, traceback = None | |
def __exit__(self, type, value, traceback): | |
> self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000021ed3fa0>, <astropy.io.fits.hdu.table.TableHDU object at 0x0000000021ed3440>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
self.flush(output_verify=output_verify, verbose=verbose) | |
finally: | |
if self._file and closed and hasattr(self._file, 'close'): | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x0000000021e86448> | |
def test_bintable_to_asciitable(self): | |
"""Tests initializing a TableHDU with the data from a BinTableHDU.""" | |
with fits.open(self.data('tb.fits')) as hdul: | |
tbdata = hdul[1].data | |
tbhdu = fits.TableHDU(data=tbdata) | |
with ignore_warnings(): | |
tbhdu.writeto(self.temp('test.fits'), overwrite=True) | |
with fits.open(self.temp('test.fits')) as hdul2: | |
tbdata2 = hdul2[1].data | |
assert np.all(tbdata['c1'] == tbdata2['c1']) | |
assert np.all(tbdata['c2'] == tbdata2['c2']) | |
# c3 gets converted from float32 to float64 when writing | |
# test.fits, so cast to float32 before testing that the correct | |
# value is retrieved | |
assert np.all(tbdata['c3'].astype(np.float32) == | |
tbdata2['c3'].astype(np.float32)) | |
# c4 is a boolean column in the original table; we want ASCII | |
# columns to convert these to columns of 'T'/'F' strings | |
> assert np.all(np.where(tbdata['c4'], 'T', 'F') == | |
tbdata2['c4']) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2325: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________________ TestTableFunctions.test_pickle ________________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000001b877280> | |
def test_pickle(self): | |
""" | |
Regression test for https://github.com/astropy/astropy/issues/1597 | |
Tests for pickling FITS_rec objects | |
""" | |
# open existing FITS tables (images pickle by default, no test needed): | |
with fits.open(self.data('tb.fits')) as btb: | |
# Test column array is delayed and can pickle | |
assert isinstance(btb[1].columns._arrays[0], Delayed) | |
btb_pd = pickle.dumps(btb[1].data) | |
btb_pl = pickle.loads(btb_pd) | |
# It should not be delayed any more | |
assert not isinstance(btb[1].columns._arrays[0], Delayed) | |
> assert comparerecords(btb_pl, btb[1].data) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2346: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________ TestTableFunctions.test_dim_column_byte_order_mismatch ____________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000001812ebb8> | |
def test_dim_column_byte_order_mismatch(self): | |
""" | |
When creating a table column with non-trivial TDIMn, and | |
big-endian array data read from an existing FITS file, the data | |
should not be unnecessarily byteswapped. | |
Regression test for https://github.com/astropy/astropy/issues/3561 | |
""" | |
> data = fits.getdata(self.data('random_groups.fits'))['DATA'] | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2387: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/convenience.py:204: in getdata | |
hdulist.close(closed=closed) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________ TestTableFunctions.test_fits_rec_from_existing ________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x00000000150e27c8> | |
def test_fits_rec_from_existing(self): | |
""" | |
Tests creating a `FITS_rec` object with `FITS_rec.from_columns` | |
from an existing `FITS_rec` object read from a FITS file. | |
This ensures that the per-column arrays are updated properly. | |
Regression test for https://github.com/spacetelescope/PyFITS/issues/99 | |
""" | |
# The use case that revealed this problem was trying to create a new | |
# table from an existing table, but with additional rows so that we can | |
# append data from a second table (with the same column structure) | |
> data1 = fits.getdata(self.data('tb.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2410: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/convenience.py:204: in getdata | |
hdulist.close(closed=closed) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________ TestTableFunctions.test_update_string_column_inplace _____________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000000c779050> | |
def test_update_string_column_inplace(self): | |
""" | |
Regression test for https://github.com/astropy/astropy/issues/4452 | |
Ensure that changes to values in a string column are saved when | |
a file is opened in ``mode='update'``. | |
""" | |
data = np.array([('abc',)], dtype=[('a', 'S3')]) | |
fits.writeto(self.temp('test.fits'), data) | |
with fits.open(self.temp('test.fits'), mode='update') as hdul: | |
hdul[1].data['a'][0] = 'XYZ' | |
> assert hdul[1].data['a'][0] == 'XYZ' | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2441: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________ TestTableFunctions.test_dump_clobber_vs_overwrite _______________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x000000000f4744b8> | |
def test_dump_clobber_vs_overwrite(self): | |
with fits.open(self.data('table.fits')) as hdul: | |
tbhdu = hdul[1] | |
datafile = self.temp('data.txt') | |
cdfile = self.temp('coldefs.txt') | |
hfile = self.temp('header.txt') | |
tbhdu.dump(datafile, cdfile, hfile) | |
tbhdu.dump(datafile, cdfile, hfile, overwrite=True) | |
with catch_warnings(AstropyDeprecationWarning) as warning_lines: | |
tbhdu.dump(datafile, cdfile, hfile, clobber=True) | |
assert warning_lines[0].category == AstropyDeprecationWarning | |
> assert (str(warning_lines[0].message) == '"clobber" was ' | |
'deprecated in version 2.0 and will be removed in a ' | |
'future version. Use argument "overwrite" instead.') | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2541: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________ TestTableFunctions.test_pseudo_unsigned_ints _________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x0000000016122b80> | |
def test_pseudo_unsigned_ints(self): | |
""" | |
Tests updating a table column containing pseudo-unsigned ints. | |
""" | |
data = np.array([1, 2, 3], dtype=np.uint32) | |
col = fits.Column(name='A', format='1J', bzero=2**31, array=data) | |
thdu = fits.BinTableHDU.from_columns([col]) | |
thdu.writeto(self.temp('test.fits')) | |
# Test that the file wrote out correctly | |
with fits.open(self.temp('test.fits'), uint=True) as hdul: | |
hdu = hdul[1] | |
assert 'TZERO1' in hdu.header | |
assert hdu.header['TZERO1'] == 2**31 | |
assert hdu.data['A'].dtype == np.dtype('uint32') | |
assert np.all(hdu.data['A'] == data) | |
# Test updating the unsigned int data | |
hdu.data['A'][0] = 99 | |
> hdu.writeto(self.temp('test2.fits')) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2565: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________ TestTableFunctions.test_column_with_scaling __________________ | |
self = <astropy.io.fits.tests.test_table.TestTableFunctions object at 0x00000000117b43d8> | |
def test_column_with_scaling(self): | |
"""Check that a scaled column if correctly saved once it is modified. | |
Regression test for https://github.com/astropy/astropy/issues/6887 | |
""" | |
c1 = fits.Column(name='c1', array=np.array([1], dtype='>i2'), | |
format='1I', bscale=1, bzero=32768) | |
S = fits.HDUList([fits.PrimaryHDU(), | |
fits.BinTableHDU.from_columns([c1])]) | |
# Change value in memory | |
S[1].data['c1'][0] = 2 | |
S.writeto(self.temp("a.fits")) | |
assert S[1].data['c1'] == 2 | |
# Read and change value in memory | |
with fits.open(self.temp("a.fits")) as X: | |
X[1].data['c1'][0] = 10 | |
assert X[1].data['c1'][0] == 10 | |
# Write back to file | |
> X.writeto(self.temp("b.fits")) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2594: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________________ TestVLATables.test_variable_length_columns __________________ | |
self = <astropy.io.fits.tests.test_table.TestVLATables object at 0x0000000012156e20> | |
def test_variable_length_columns(self): | |
def test(format_code): | |
col = fits.Column(name='QUAL_SPE', format=format_code, | |
array=[[0] * 1571] * 225) | |
tb_hdu = fits.BinTableHDU.from_columns([col]) | |
pri_hdu = fits.PrimaryHDU() | |
hdu_list = fits.HDUList([pri_hdu, tb_hdu]) | |
with ignore_warnings(): | |
hdu_list.writeto(self.temp('toto.fits'), overwrite=True) | |
with fits.open(self.temp('toto.fits')) as toto: | |
q = toto[1].data.field('QUAL_SPE') | |
assert (q[0][4:8] == | |
np.array([0, 0, 0, 0], dtype=np.uint8)).all() | |
assert toto[1].columns[0].format.endswith('J(1571)') | |
for code in ('PJ()', 'QJ()'): | |
> test(code) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2638: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2635: in test | |
assert toto[1].columns[0].format.endswith('J(1571)') | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____ TestVLATables.test_variable_length_table_format_pd_from_object_array _____ | |
self = <astropy.io.fits.tests.test_table.TestVLATables object at 0x00000000210851d8> | |
def test_variable_length_table_format_pd_from_object_array(self): | |
def test(format_code): | |
a = np.array([np.array([7.2e-20, 7.3e-20]), np.array([0.0]), | |
np.array([0.0])], 'O') | |
acol = fits.Column(name='testa', format=format_code, array=a) | |
tbhdu = fits.BinTableHDU.from_columns([acol]) | |
with ignore_warnings(): | |
tbhdu.writeto(self.temp('newtable.fits'), overwrite=True) | |
with fits.open(self.temp('newtable.fits')) as tbhdu1: | |
assert tbhdu1[1].columns[0].format.endswith('D(2)') | |
for j in range(3): | |
for i in range(len(a[j])): | |
assert tbhdu1[1].data.field(0)[j][i] == a[j][i] | |
for code in ('PD()', 'QD()'): | |
> test(code) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2677: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2674: in test | |
assert tbhdu1[1].data.field(0)[j][i] == a[j][i] | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________ TestVLATables.test_variable_length_table_format_pd_from_list _________ | |
self = <astropy.io.fits.tests.test_table.TestVLATables object at 0x0000000023902218> | |
def test_variable_length_table_format_pd_from_list(self): | |
def test(format_code): | |
a = [np.array([7.2e-20, 7.3e-20]), np.array([0.0]), | |
np.array([0.0])] | |
acol = fits.Column(name='testa', format=format_code, array=a) | |
tbhdu = fits.BinTableHDU.from_columns([acol]) | |
with ignore_warnings(): | |
tbhdu.writeto(self.temp('newtable.fits'), overwrite=True) | |
with fits.open(self.temp('newtable.fits')) as tbhdu1: | |
assert tbhdu1[1].columns[0].format.endswith('D(2)') | |
for j in range(3): | |
for i in range(len(a[j])): | |
assert tbhdu1[1].data.field(0)[j][i] == a[j][i] | |
for code in ('PD()', 'QD()'): | |
> test(code) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2695: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2692: in test | |
assert tbhdu1[1].data.field(0)[j][i] == a[j][i] | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____ TestVLATables.test_variable_length_table_format_pa_from_object_array _____ | |
self = <astropy.io.fits.tests.test_table.TestVLATables object at 0x000000000bde9398> | |
def test_variable_length_table_format_pa_from_object_array(self): | |
def test(format_code): | |
a = np.array([np.array(['a', 'b', 'c']), np.array(['d', 'e']), | |
np.array(['f'])], 'O') | |
acol = fits.Column(name='testa', format=format_code, array=a) | |
tbhdu = fits.BinTableHDU.from_columns([acol]) | |
with ignore_warnings(): | |
tbhdu.writeto(self.temp('newtable.fits'), overwrite=True) | |
with fits.open(self.temp('newtable.fits')) as hdul: | |
assert hdul[1].columns[0].format.endswith('A(3)') | |
for j in range(3): | |
for i in range(len(a[j])): | |
assert hdul[1].data.field(0)[j][i] == a[j][i] | |
for code in ('PA()', 'QA()'): | |
> test(code) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2713: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2710: in test | |
assert hdul[1].data.field(0)[j][i] == a[j][i] | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________ TestVLATables.test_variable_length_table_format_pa_from_list _________ | |
self = <astropy.io.fits.tests.test_table.TestVLATables object at 0x000000001f1428a8> | |
def test_variable_length_table_format_pa_from_list(self): | |
def test(format_code): | |
a = ['a', 'ab', 'abc'] | |
acol = fits.Column(name='testa', format=format_code, array=a) | |
tbhdu = fits.BinTableHDU.from_columns([acol]) | |
with ignore_warnings(): | |
tbhdu.writeto(self.temp('newtable.fits'), overwrite=True) | |
with fits.open(self.temp('newtable.fits')) as hdul: | |
assert hdul[1].columns[0].format.endswith('A(3)') | |
for j in range(3): | |
for i in range(len(a[j])): | |
assert hdul[1].data.field(0)[j][i] == a[j][i] | |
for code in ('PA()', 'QA()'): | |
> test(code) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2730: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2727: in test | |
assert hdul[1].data.field(0)[j][i] == a[j][i] | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________________ TestVLATables.test_getdata_vla ________________________ | |
self = <astropy.io.fits.tests.test_table.TestVLATables object at 0x000000000c0aa9f8> | |
def test_getdata_vla(self): | |
"""Regression test for https://aeon.stsci.edu/ssb/trac/pyfits/ticket/200""" | |
def test(format_code): | |
col = fits.Column(name='QUAL_SPE', format=format_code, | |
array=[np.arange(1572)] * 225) | |
tb_hdu = fits.BinTableHDU.from_columns([col]) | |
pri_hdu = fits.PrimaryHDU() | |
hdu_list = fits.HDUList([pri_hdu, tb_hdu]) | |
with ignore_warnings(): | |
hdu_list.writeto(self.temp('toto.fits'), overwrite=True) | |
data = fits.getdata(self.temp('toto.fits')) | |
# Need to compare to the original data row by row since the FITS_rec | |
# returns an array of _VLA objects | |
for row_a, row_b in zip(data['QUAL_SPE'], col.array): | |
assert (row_a == row_b).all() | |
for code in ('PJ()', 'QJ()'): | |
> test(code) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2752: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2744: in test | |
data = fits.getdata(self.temp('toto.fits')) | |
pypy/site-packages/astropy/io/fits/convenience.py:204: in getdata | |
hdulist.close(closed=closed) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________________ TestVLATables.test_copy_vla __________________________ | |
self = <astropy.io.fits.tests.test_table.TestVLATables object at 0x00000000119d5d00> | |
def test_copy_vla(self): | |
""" | |
Regression test for https://github.com/spacetelescope/PyFITS/issues/47 | |
""" | |
# Make a file containing a couple of VLA tables | |
arr1 = [np.arange(n + 1) for n in range(255)] | |
arr2 = [np.arange(255, 256 + n) for n in range(255)] | |
# A dummy non-VLA column needed to reproduce issue #47 | |
c = fits.Column('test', format='J', array=np.arange(255)) | |
c1 = fits.Column('A', format='PJ', array=arr1) | |
c2 = fits.Column('B', format='PJ', array=arr2) | |
t1 = fits.BinTableHDU.from_columns([c, c1]) | |
t2 = fits.BinTableHDU.from_columns([c, c2]) | |
hdul = fits.HDUList([fits.PrimaryHDU(), t1, t2]) | |
hdul.writeto(self.temp('test.fits'), overwrite=True) | |
# Just test that the test file wrote out correctly | |
with fits.open(self.temp('test.fits')) as h: | |
assert h[1].header['TFORM2'] == 'PJ(255)' | |
assert h[2].header['TFORM2'] == 'PJ(255)' | |
assert comparerecords(h[1].data, t1.data) | |
> assert comparerecords(h[2].data, t2.data) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2778: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________ TestColumnFunctions.test_zero_precision_float_column _____________ | |
self = <astropy.io.fits.tests.test_table.TestColumnFunctions object at 0x00000000128703d8> | |
def test_zero_precision_float_column(self): | |
""" | |
Regression test for https://github.com/astropy/astropy/issues/3422 | |
""" | |
c = fits.Column('TEST', 'F5.0', array=[1.1, 2.2, 3.3]) | |
# The decimal places will be clipped | |
t = fits.TableHDU.from_columns([c]) | |
t.writeto(self.temp('test.fits')) | |
with fits.open(self.temp('test.fits')) as hdul: | |
assert hdul[1].header['TFORM1'] == 'F5.0' | |
assert hdul[1].data['TEST'].dtype == np.dtype('float64') | |
assert np.all(hdul[1].data['TEST'] == [1.0, 2.0, 3.0]) | |
# Check how the raw data looks | |
raw = np.rec.recarray.field(hdul[1].data, 'TEST') | |
> assert raw.tostring() == b' 1. 2. 3.' | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2913: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________________ TestColumnFunctions.test_pickle ________________________ | |
self = <astropy.io.fits.tests.test_table.TestColumnFunctions object at 0x000000002234b248> | |
def test_pickle(self): | |
""" | |
Regression test for https://github.com/astropy/astropy/issues/1597 | |
Tests for pickling FITS_rec objects | |
""" | |
# open existing FITS tables (images pickle by default, no test needed): | |
with fits.open(self.data('tb.fits')) as btb: | |
# Test column array is delayed and can pickle | |
assert isinstance(btb[1].columns._arrays[0], Delayed) | |
btb_pd = pickle.dumps(btb[1].data) | |
btb_pl = pickle.loads(btb_pd) | |
# It should not be delayed any more | |
assert not isinstance(btb[1].columns._arrays[0], Delayed) | |
> assert comparerecords(btb_pl, btb[1].data) | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:2956: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________________________ test_empty_table _______________________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_empty_table0') | |
def test_empty_table(tmpdir): | |
ofile = str(tmpdir.join('emptytable.fits')) | |
hdu = fits.BinTableHDU(header=None, data=None, name='TEST') | |
hdu.writeto(ofile) | |
with fits.open(ofile) as hdul: | |
> assert hdul['TEST'].data.size == 0 | |
pypy/site-packages/astropy/io/fits/tests/test_table.py:3279: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________________ TestUintFunctions.test_uint[u2-False] _____________________ | |
self = <astropy.io.fits.tests.test_uint.TestUintFunctions object at 0x0000000023961c20> | |
utype = 'u2', compressed = False | |
@pytest.mark.parametrize(('utype', 'compressed'), | |
[('u2', False), ('u4', False), ('u8', False), ('u2', True), | |
('u4', True)]) # ,('u8',True)]) | |
def test_uint(self, utype, compressed): | |
bits = 8*int(utype[1]) | |
if platform.architecture()[0] == '64bit' or bits != 64: | |
if compressed: | |
hdu = fits.CompImageHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 1 | |
else: | |
hdu = fits.PrimaryHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 0 | |
hdu.scale(f'int{bits:d}', '', bzero=2 ** (bits-1)) | |
with ignore_warnings(): | |
hdu.writeto(self.temp('tempfile.fits'), overwrite=True) | |
with fits.open(self.temp('tempfile.fits'), uint=True) as hdul: | |
assert hdul[hdu_number].data.dtype == self.utype_map[utype] | |
assert (hdul[hdu_number].data == np.array( | |
[(2 ** bits) - 3, (2 ** bits) - 2, (2 ** bits) - 1, | |
0, 1, 2, 3], | |
dtype=self.utype_map[utype])).all() | |
hdul.writeto(self.temp('tempfile1.fits')) | |
with fits.open(self.temp('tempfile1.fits'), | |
uint16=True) as hdul1: | |
d1 = hdul[hdu_number].data | |
d2 = hdul1[hdu_number].data | |
assert (d1 == d2).all() | |
if not compressed: | |
# TODO: Enable these lines if CompImageHDUs ever grow | |
# .section support | |
sec = hdul[hdu_number].section[:1] | |
assert sec.dtype.name == f'uint{bits}' | |
> assert (sec == d1[:1]).all() | |
pypy/site-packages/astropy/io/fits/tests/test_uint.py:59: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000002391f328>] | |
type = None, value = None, traceback = None | |
def __exit__(self, type, value, traceback): | |
> self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000002391f328>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
self.flush(output_verify=output_verify, verbose=verbose) | |
finally: | |
if self._file and closed and hasattr(self._file, 'close'): | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_uint.TestUintFunctions object at 0x0000000023961c20> | |
utype = 'u2', compressed = False | |
@pytest.mark.parametrize(('utype', 'compressed'), | |
[('u2', False), ('u4', False), ('u8', False), ('u2', True), | |
('u4', True)]) # ,('u8',True)]) | |
def test_uint(self, utype, compressed): | |
bits = 8*int(utype[1]) | |
if platform.architecture()[0] == '64bit' or bits != 64: | |
if compressed: | |
hdu = fits.CompImageHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 1 | |
else: | |
hdu = fits.PrimaryHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 0 | |
hdu.scale(f'int{bits:d}', '', bzero=2 ** (bits-1)) | |
with ignore_warnings(): | |
hdu.writeto(self.temp('tempfile.fits'), overwrite=True) | |
with fits.open(self.temp('tempfile.fits'), uint=True) as hdul: | |
assert hdul[hdu_number].data.dtype == self.utype_map[utype] | |
assert (hdul[hdu_number].data == np.array( | |
[(2 ** bits) - 3, (2 ** bits) - 2, (2 ** bits) - 1, | |
0, 1, 2, 3], | |
dtype=self.utype_map[utype])).all() | |
hdul.writeto(self.temp('tempfile1.fits')) | |
with fits.open(self.temp('tempfile1.fits'), | |
uint16=True) as hdul1: | |
d1 = hdul[hdu_number].data | |
d2 = hdul1[hdu_number].data | |
assert (d1 == d2).all() | |
if not compressed: | |
# TODO: Enable these lines if CompImageHDUs ever grow | |
# .section support | |
sec = hdul[hdu_number].section[:1] | |
assert sec.dtype.name == f'uint{bits}' | |
> assert (sec == d1[:1]).all() | |
pypy/site-packages/astropy/io/fits/tests/test_uint.py:59: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________________ TestUintFunctions.test_uint[u4-False] _____________________ | |
self = <astropy.io.fits.tests.test_uint.TestUintFunctions object at 0x00000000149eb6a8> | |
utype = 'u4', compressed = False | |
@pytest.mark.parametrize(('utype', 'compressed'), | |
[('u2', False), ('u4', False), ('u8', False), ('u2', True), | |
('u4', True)]) # ,('u8',True)]) | |
def test_uint(self, utype, compressed): | |
bits = 8*int(utype[1]) | |
if platform.architecture()[0] == '64bit' or bits != 64: | |
if compressed: | |
hdu = fits.CompImageHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 1 | |
else: | |
hdu = fits.PrimaryHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 0 | |
hdu.scale(f'int{bits:d}', '', bzero=2 ** (bits-1)) | |
with ignore_warnings(): | |
hdu.writeto(self.temp('tempfile.fits'), overwrite=True) | |
with fits.open(self.temp('tempfile.fits'), uint=True) as hdul: | |
assert hdul[hdu_number].data.dtype == self.utype_map[utype] | |
assert (hdul[hdu_number].data == np.array( | |
[(2 ** bits) - 3, (2 ** bits) - 2, (2 ** bits) - 1, | |
0, 1, 2, 3], | |
dtype=self.utype_map[utype])).all() | |
hdul.writeto(self.temp('tempfile1.fits')) | |
with fits.open(self.temp('tempfile1.fits'), | |
uint16=True) as hdul1: | |
d1 = hdul[hdu_number].data | |
d2 = hdul1[hdu_number].data | |
assert (d1 == d2).all() | |
if not compressed: | |
# TODO: Enable these lines if CompImageHDUs ever grow | |
# .section support | |
sec = hdul[hdu_number].section[:1] | |
assert sec.dtype.name == f'uint{bits}' | |
> assert (sec == d1[:1]).all() | |
pypy/site-packages/astropy/io/fits/tests/test_uint.py:59: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000013c80de8>] | |
type = None, value = None, traceback = None | |
def __exit__(self, type, value, traceback): | |
> self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000013c80de8>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
self.flush(output_verify=output_verify, verbose=verbose) | |
finally: | |
if self._file and closed and hasattr(self._file, 'close'): | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_uint.TestUintFunctions object at 0x00000000149eb6a8> | |
utype = 'u4', compressed = False | |
@pytest.mark.parametrize(('utype', 'compressed'), | |
[('u2', False), ('u4', False), ('u8', False), ('u2', True), | |
('u4', True)]) # ,('u8',True)]) | |
def test_uint(self, utype, compressed): | |
bits = 8*int(utype[1]) | |
if platform.architecture()[0] == '64bit' or bits != 64: | |
if compressed: | |
hdu = fits.CompImageHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 1 | |
else: | |
hdu = fits.PrimaryHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 0 | |
hdu.scale(f'int{bits:d}', '', bzero=2 ** (bits-1)) | |
with ignore_warnings(): | |
hdu.writeto(self.temp('tempfile.fits'), overwrite=True) | |
with fits.open(self.temp('tempfile.fits'), uint=True) as hdul: | |
assert hdul[hdu_number].data.dtype == self.utype_map[utype] | |
assert (hdul[hdu_number].data == np.array( | |
[(2 ** bits) - 3, (2 ** bits) - 2, (2 ** bits) - 1, | |
0, 1, 2, 3], | |
dtype=self.utype_map[utype])).all() | |
hdul.writeto(self.temp('tempfile1.fits')) | |
with fits.open(self.temp('tempfile1.fits'), | |
uint16=True) as hdul1: | |
d1 = hdul[hdu_number].data | |
d2 = hdul1[hdu_number].data | |
assert (d1 == d2).all() | |
if not compressed: | |
# TODO: Enable these lines if CompImageHDUs ever grow | |
# .section support | |
sec = hdul[hdu_number].section[:1] | |
assert sec.dtype.name == f'uint{bits}' | |
> assert (sec == d1[:1]).all() | |
pypy/site-packages/astropy/io/fits/tests/test_uint.py:59: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________________ TestUintFunctions.test_uint[u8-False] _____________________ | |
self = <astropy.io.fits.tests.test_uint.TestUintFunctions object at 0x0000000009452250> | |
utype = 'u8', compressed = False | |
@pytest.mark.parametrize(('utype', 'compressed'), | |
[('u2', False), ('u4', False), ('u8', False), ('u2', True), | |
('u4', True)]) # ,('u8',True)]) | |
def test_uint(self, utype, compressed): | |
bits = 8*int(utype[1]) | |
if platform.architecture()[0] == '64bit' or bits != 64: | |
if compressed: | |
hdu = fits.CompImageHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 1 | |
else: | |
hdu = fits.PrimaryHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 0 | |
hdu.scale(f'int{bits:d}', '', bzero=2 ** (bits-1)) | |
with ignore_warnings(): | |
hdu.writeto(self.temp('tempfile.fits'), overwrite=True) | |
with fits.open(self.temp('tempfile.fits'), uint=True) as hdul: | |
assert hdul[hdu_number].data.dtype == self.utype_map[utype] | |
assert (hdul[hdu_number].data == np.array( | |
[(2 ** bits) - 3, (2 ** bits) - 2, (2 ** bits) - 1, | |
0, 1, 2, 3], | |
dtype=self.utype_map[utype])).all() | |
hdul.writeto(self.temp('tempfile1.fits')) | |
with fits.open(self.temp('tempfile1.fits'), | |
uint16=True) as hdul1: | |
d1 = hdul[hdu_number].data | |
d2 = hdul1[hdu_number].data | |
assert (d1 == d2).all() | |
if not compressed: | |
# TODO: Enable these lines if CompImageHDUs ever grow | |
# .section support | |
sec = hdul[hdu_number].section[:1] | |
assert sec.dtype.name == f'uint{bits}' | |
> assert (sec == d1[:1]).all() | |
pypy/site-packages/astropy/io/fits/tests/test_uint.py:59: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000006f81b40>] | |
type = None, value = None, traceback = None | |
def __exit__(self, type, value, traceback): | |
> self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x0000000006f81b40>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
self.flush(output_verify=output_verify, verbose=verbose) | |
finally: | |
if self._file and closed and hasattr(self._file, 'close'): | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_uint.TestUintFunctions object at 0x0000000009452250> | |
utype = 'u8', compressed = False | |
@pytest.mark.parametrize(('utype', 'compressed'), | |
[('u2', False), ('u4', False), ('u8', False), ('u2', True), | |
('u4', True)]) # ,('u8',True)]) | |
def test_uint(self, utype, compressed): | |
bits = 8*int(utype[1]) | |
if platform.architecture()[0] == '64bit' or bits != 64: | |
if compressed: | |
hdu = fits.CompImageHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 1 | |
else: | |
hdu = fits.PrimaryHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 0 | |
hdu.scale(f'int{bits:d}', '', bzero=2 ** (bits-1)) | |
with ignore_warnings(): | |
hdu.writeto(self.temp('tempfile.fits'), overwrite=True) | |
with fits.open(self.temp('tempfile.fits'), uint=True) as hdul: | |
assert hdul[hdu_number].data.dtype == self.utype_map[utype] | |
assert (hdul[hdu_number].data == np.array( | |
[(2 ** bits) - 3, (2 ** bits) - 2, (2 ** bits) - 1, | |
0, 1, 2, 3], | |
dtype=self.utype_map[utype])).all() | |
hdul.writeto(self.temp('tempfile1.fits')) | |
with fits.open(self.temp('tempfile1.fits'), | |
uint16=True) as hdul1: | |
d1 = hdul[hdu_number].data | |
d2 = hdul1[hdu_number].data | |
assert (d1 == d2).all() | |
if not compressed: | |
# TODO: Enable these lines if CompImageHDUs ever grow | |
# .section support | |
sec = hdul[hdu_number].section[:1] | |
assert sec.dtype.name == f'uint{bits}' | |
> assert (sec == d1[:1]).all() | |
pypy/site-packages/astropy/io/fits/tests/test_uint.py:59: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________________ TestUintFunctions.test_uint[u2-True] _____________________ | |
self = <astropy.io.fits.tests.test_uint.TestUintFunctions object at 0x0000000022d676e0> | |
utype = 'u2', compressed = True | |
@pytest.mark.parametrize(('utype', 'compressed'), | |
[('u2', False), ('u4', False), ('u8', False), ('u2', True), | |
('u4', True)]) # ,('u8',True)]) | |
def test_uint(self, utype, compressed): | |
bits = 8*int(utype[1]) | |
if platform.architecture()[0] == '64bit' or bits != 64: | |
if compressed: | |
hdu = fits.CompImageHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 1 | |
else: | |
hdu = fits.PrimaryHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 0 | |
hdu.scale(f'int{bits:d}', '', bzero=2 ** (bits-1)) | |
with ignore_warnings(): | |
hdu.writeto(self.temp('tempfile.fits'), overwrite=True) | |
with fits.open(self.temp('tempfile.fits'), uint=True) as hdul: | |
assert hdul[hdu_number].data.dtype == self.utype_map[utype] | |
assert (hdul[hdu_number].data == np.array( | |
[(2 ** bits) - 3, (2 ** bits) - 2, (2 ** bits) - 1, | |
0, 1, 2, 3], | |
dtype=self.utype_map[utype])).all() | |
hdul.writeto(self.temp('tempfile1.fits')) | |
with fits.open(self.temp('tempfile1.fits'), | |
uint16=True) as hdul1: | |
d1 = hdul[hdu_number].data | |
d2 = hdul1[hdu_number].data | |
assert (d1 == d2).all() | |
if not compressed: | |
# TODO: Enable these lines if CompImageHDUs ever grow | |
# .section support | |
sec = hdul[hdu_number].section[:1] | |
assert sec.dtype.name == f'uint{bits}' | |
> assert (sec == d1[:1]).all() | |
pypy/site-packages/astropy/io/fits/tests/test_uint.py:59: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000001b18b2f0>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x000000001b18a790>] | |
type = None, value = None, traceback = None | |
def __exit__(self, type, value, traceback): | |
> self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000001b18b2f0>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x000000001b18a790>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
self.flush(output_verify=output_verify, verbose=verbose) | |
finally: | |
if self._file and closed and hasattr(self._file, 'close'): | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_uint.TestUintFunctions object at 0x0000000022d676e0> | |
utype = 'u2', compressed = True | |
@pytest.mark.parametrize(('utype', 'compressed'), | |
[('u2', False), ('u4', False), ('u8', False), ('u2', True), | |
('u4', True)]) # ,('u8',True)]) | |
def test_uint(self, utype, compressed): | |
bits = 8*int(utype[1]) | |
if platform.architecture()[0] == '64bit' or bits != 64: | |
if compressed: | |
hdu = fits.CompImageHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 1 | |
else: | |
hdu = fits.PrimaryHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 0 | |
hdu.scale(f'int{bits:d}', '', bzero=2 ** (bits-1)) | |
with ignore_warnings(): | |
hdu.writeto(self.temp('tempfile.fits'), overwrite=True) | |
with fits.open(self.temp('tempfile.fits'), uint=True) as hdul: | |
assert hdul[hdu_number].data.dtype == self.utype_map[utype] | |
assert (hdul[hdu_number].data == np.array( | |
[(2 ** bits) - 3, (2 ** bits) - 2, (2 ** bits) - 1, | |
0, 1, 2, 3], | |
dtype=self.utype_map[utype])).all() | |
hdul.writeto(self.temp('tempfile1.fits')) | |
with fits.open(self.temp('tempfile1.fits'), | |
uint16=True) as hdul1: | |
d1 = hdul[hdu_number].data | |
d2 = hdul1[hdu_number].data | |
assert (d1 == d2).all() | |
if not compressed: | |
# TODO: Enable these lines if CompImageHDUs ever grow | |
# .section support | |
sec = hdul[hdu_number].section[:1] | |
assert sec.dtype.name == f'uint{bits}' | |
> assert (sec == d1[:1]).all() | |
pypy/site-packages/astropy/io/fits/tests/test_uint.py:59: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________________ TestUintFunctions.test_uint[u4-True] _____________________ | |
self = <astropy.io.fits.tests.test_uint.TestUintFunctions object at 0x000000001aeb0a30> | |
utype = 'u4', compressed = True | |
@pytest.mark.parametrize(('utype', 'compressed'), | |
[('u2', False), ('u4', False), ('u8', False), ('u2', True), | |
('u4', True)]) # ,('u8',True)]) | |
def test_uint(self, utype, compressed): | |
bits = 8*int(utype[1]) | |
if platform.architecture()[0] == '64bit' or bits != 64: | |
if compressed: | |
hdu = fits.CompImageHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 1 | |
else: | |
hdu = fits.PrimaryHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 0 | |
hdu.scale(f'int{bits:d}', '', bzero=2 ** (bits-1)) | |
with ignore_warnings(): | |
hdu.writeto(self.temp('tempfile.fits'), overwrite=True) | |
with fits.open(self.temp('tempfile.fits'), uint=True) as hdul: | |
assert hdul[hdu_number].data.dtype == self.utype_map[utype] | |
assert (hdul[hdu_number].data == np.array( | |
[(2 ** bits) - 3, (2 ** bits) - 2, (2 ** bits) - 1, | |
0, 1, 2, 3], | |
dtype=self.utype_map[utype])).all() | |
hdul.writeto(self.temp('tempfile1.fits')) | |
with fits.open(self.temp('tempfile1.fits'), | |
uint16=True) as hdul1: | |
d1 = hdul[hdu_number].data | |
d2 = hdul1[hdu_number].data | |
assert (d1 == d2).all() | |
if not compressed: | |
# TODO: Enable these lines if CompImageHDUs ever grow | |
# .section support | |
sec = hdul[hdu_number].section[:1] | |
assert sec.dtype.name == f'uint{bits}' | |
> assert (sec == d1[:1]).all() | |
pypy/site-packages/astropy/io/fits/tests/test_uint.py:59: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000000d5413d0>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x000000000d540678>] | |
type = None, value = None, traceback = None | |
def __exit__(self, type, value, traceback): | |
> self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000000d5413d0>, <astropy.io.fits.hdu.compressed.CompImageHDU object at 0x000000000d540678>] | |
output_verify = 'exception', verbose = False, closed = True | |
def close(self, output_verify='exception', verbose=False, closed=True): | |
""" | |
Close the associated FITS file and memmap object, if any. | |
Parameters | |
---------- | |
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. | |
verbose : bool | |
When `True`, print out verbose messages. | |
closed : bool | |
When `True`, close the underlying file object. | |
""" | |
try: | |
if (self._file and self._file.mode in ('append', 'update') | |
and not self._file.closed): | |
self.flush(output_verify=output_verify, verbose=verbose) | |
finally: | |
if self._file and closed and hasattr(self._file, 'close'): | |
> self._file.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>> | |
def close(self): | |
""" | |
Close the 'physical' FITS file. | |
""" | |
if hasattr(self._file, 'close'): | |
self._file.close() | |
> self._maybe_close_mmap() | |
pypy/site-packages/astropy/io/fits/file.py:413: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
During handling of the above exception, another exception occurred: | |
self = <astropy.io.fits.tests.test_uint.TestUintFunctions object at 0x000000001aeb0a30> | |
utype = 'u4', compressed = True | |
@pytest.mark.parametrize(('utype', 'compressed'), | |
[('u2', False), ('u4', False), ('u8', False), ('u2', True), | |
('u4', True)]) # ,('u8',True)]) | |
def test_uint(self, utype, compressed): | |
bits = 8*int(utype[1]) | |
if platform.architecture()[0] == '64bit' or bits != 64: | |
if compressed: | |
hdu = fits.CompImageHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 1 | |
else: | |
hdu = fits.PrimaryHDU(np.array([-3, -2, -1, 0, 1, 2, 3], dtype=np.int64)) | |
hdu_number = 0 | |
hdu.scale(f'int{bits:d}', '', bzero=2 ** (bits-1)) | |
with ignore_warnings(): | |
hdu.writeto(self.temp('tempfile.fits'), overwrite=True) | |
with fits.open(self.temp('tempfile.fits'), uint=True) as hdul: | |
assert hdul[hdu_number].data.dtype == self.utype_map[utype] | |
assert (hdul[hdu_number].data == np.array( | |
[(2 ** bits) - 3, (2 ** bits) - 2, (2 ** bits) - 1, | |
0, 1, 2, 3], | |
dtype=self.utype_map[utype])).all() | |
hdul.writeto(self.temp('tempfile1.fits')) | |
with fits.open(self.temp('tempfile1.fits'), | |
uint16=True) as hdul1: | |
d1 = hdul[hdu_number].data | |
d2 = hdul1[hdu_number].data | |
assert (d1 == d2).all() | |
if not compressed: | |
# TODO: Enable these lines if CompImageHDUs ever grow | |
# .section support | |
sec = hdul[hdu_number].section[:1] | |
assert sec.dtype.name == f'uint{bits}' | |
> assert (sec == d1[:1]).all() | |
pypy/site-packages/astropy/io/fits/tests/test_uint.py:59: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ TestUintFunctions.test_uint_columns[u2] ____________________ | |
self = <astropy.io.fits.tests.test_uint.TestUintFunctions object at 0x00000000067fb1d8> | |
utype = 'u2' | |
@pytest.mark.parametrize('utype', ('u2', 'u4', 'u8')) | |
def test_uint_columns(self, utype): | |
"""Test basic functionality of tables with columns containing | |
pseudo-unsigned integers. See | |
https://github.com/astropy/astropy/pull/906 | |
""" | |
bits = 8*int(utype[1]) | |
if platform.architecture()[0] == '64bit' or bits != 64: | |
bzero = self.utype_map[utype](2**(bits-1)) | |
one = self.utype_map[utype](1) | |
u0 = np.arange(bits+1, dtype=self.utype_map[utype]) | |
u = 2**u0 - one | |
if bits == 64: | |
u[63] = bzero - one | |
u[64] = u[63] + u[63] + one | |
uu = (u - bzero).view(self.itype_map[utype]) | |
# Construct a table from explicit column | |
col = fits.Column(name=utype, array=u, | |
format=self.format_map[utype], bzero=bzero) | |
table = fits.BinTableHDU.from_columns([col]) | |
assert (table.data[utype] == u).all() | |
# This used to be table.data.base, but now after adding a table to | |
# a BinTableHDU it gets stored as a view of the original table, | |
# even if the original was already a FITS_rec. So now we need | |
# table.data.base.base | |
assert (table.data.base.base[utype] == uu).all() | |
hdu0 = fits.PrimaryHDU() | |
hdulist = fits.HDUList([hdu0, table]) | |
with ignore_warnings(): | |
hdulist.writeto(self.temp('tempfile.fits'), overwrite=True) | |
# Test write of unsigned int | |
del hdulist | |
with fits.open(self.temp('tempfile.fits'), uint=True) as hdulist2: | |
hdudata = hdulist2[1].data | |
assert (hdudata[utype] == u).all() | |
assert (hdudata[utype].dtype == self.utype_map[utype]) | |
> assert (hdudata.base[utype] == uu).all() | |
pypy/site-packages/astropy/io/fits/tests/test_uint.py:102: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ TestUintFunctions.test_uint_columns[u4] ____________________ | |
self = <astropy.io.fits.tests.test_uint.TestUintFunctions object at 0x000000001812eb10> | |
utype = 'u4' | |
@pytest.mark.parametrize('utype', ('u2', 'u4', 'u8')) | |
def test_uint_columns(self, utype): | |
"""Test basic functionality of tables with columns containing | |
pseudo-unsigned integers. See | |
https://github.com/astropy/astropy/pull/906 | |
""" | |
bits = 8*int(utype[1]) | |
if platform.architecture()[0] == '64bit' or bits != 64: | |
bzero = self.utype_map[utype](2**(bits-1)) | |
one = self.utype_map[utype](1) | |
u0 = np.arange(bits+1, dtype=self.utype_map[utype]) | |
u = 2**u0 - one | |
if bits == 64: | |
u[63] = bzero - one | |
u[64] = u[63] + u[63] + one | |
uu = (u - bzero).view(self.itype_map[utype]) | |
# Construct a table from explicit column | |
col = fits.Column(name=utype, array=u, | |
format=self.format_map[utype], bzero=bzero) | |
table = fits.BinTableHDU.from_columns([col]) | |
assert (table.data[utype] == u).all() | |
# This used to be table.data.base, but now after adding a table to | |
# a BinTableHDU it gets stored as a view of the original table, | |
# even if the original was already a FITS_rec. So now we need | |
# table.data.base.base | |
assert (table.data.base.base[utype] == uu).all() | |
hdu0 = fits.PrimaryHDU() | |
hdulist = fits.HDUList([hdu0, table]) | |
with ignore_warnings(): | |
hdulist.writeto(self.temp('tempfile.fits'), overwrite=True) | |
# Test write of unsigned int | |
del hdulist | |
with fits.open(self.temp('tempfile.fits'), uint=True) as hdulist2: | |
hdudata = hdulist2[1].data | |
assert (hdudata[utype] == u).all() | |
assert (hdudata[utype].dtype == self.utype_map[utype]) | |
> assert (hdudata.base[utype] == uu).all() | |
pypy/site-packages/astropy/io/fits/tests/test_uint.py:102: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ TestUintFunctions.test_uint_columns[u8] ____________________ | |
self = <astropy.io.fits.tests.test_uint.TestUintFunctions object at 0x000000000f204170> | |
utype = 'u8' | |
@pytest.mark.parametrize('utype', ('u2', 'u4', 'u8')) | |
def test_uint_columns(self, utype): | |
"""Test basic functionality of tables with columns containing | |
pseudo-unsigned integers. See | |
https://github.com/astropy/astropy/pull/906 | |
""" | |
bits = 8*int(utype[1]) | |
if platform.architecture()[0] == '64bit' or bits != 64: | |
bzero = self.utype_map[utype](2**(bits-1)) | |
one = self.utype_map[utype](1) | |
u0 = np.arange(bits+1, dtype=self.utype_map[utype]) | |
u = 2**u0 - one | |
if bits == 64: | |
u[63] = bzero - one | |
u[64] = u[63] + u[63] + one | |
uu = (u - bzero).view(self.itype_map[utype]) | |
# Construct a table from explicit column | |
col = fits.Column(name=utype, array=u, | |
format=self.format_map[utype], bzero=bzero) | |
table = fits.BinTableHDU.from_columns([col]) | |
assert (table.data[utype] == u).all() | |
# This used to be table.data.base, but now after adding a table to | |
# a BinTableHDU it gets stored as a view of the original table, | |
# even if the original was already a FITS_rec. So now we need | |
# table.data.base.base | |
assert (table.data.base.base[utype] == uu).all() | |
hdu0 = fits.PrimaryHDU() | |
hdulist = fits.HDUList([hdu0, table]) | |
with ignore_warnings(): | |
hdulist.writeto(self.temp('tempfile.fits'), overwrite=True) | |
# Test write of unsigned int | |
del hdulist | |
with fits.open(self.temp('tempfile.fits'), uint=True) as hdulist2: | |
hdudata = hdulist2[1].data | |
assert (hdudata[utype] == u).all() | |
assert (hdudata[utype].dtype == self.utype_map[utype]) | |
> assert (hdudata.base[utype] == uu).all() | |
pypy/site-packages/astropy/io/fits/tests/test_uint.py:102: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________________ TestUintFunctions.test_uint_slice _______________________ | |
self = <astropy.io.fits.tests.test_uint.TestUintFunctions object at 0x00000000180d52b8> | |
def test_uint_slice(self): | |
""" | |
Fix for https://github.com/astropy/astropy/issues/5490 | |
if data is sliced first, make sure the data is still converted as uint | |
""" | |
# create_data: | |
dataref = np.arange(2**16, dtype=np.uint16) | |
tbhdu = fits.BinTableHDU.from_columns([ | |
fits.Column(name='a', format='I', | |
array=np.arange(2**16, dtype=np.int16)), | |
fits.Column(name='b', format='I', bscale=1, bzero=2**15, | |
array=dataref) | |
]) | |
tbhdu.writeto(self.temp('test_scaled_slicing.fits')) | |
with fits.open(self.temp('test_scaled_slicing.fits')) as hdulist: | |
> data = hdulist[1].data | |
pypy/site-packages/astropy/io/fits/tests/test_uint.py:133: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________________________ test_gzip_filehandles _____________________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_gzip_filehandles0') | |
def test_gzip_filehandles(tmpdir): | |
votable = parse(get_pkg_data_filename('data/regression.xml')) | |
# W39: Bit values can not be masked | |
with pytest.warns(W39): | |
with open(str(tmpdir.join("regression.compressed.xml")), 'wb') as fd: | |
votable.to_xml(fd, compressed=True, _astropy_version="testing") | |
with open(str(tmpdir.join("regression.compressed.xml")), 'rb') as fd: | |
> votable = parse(fd) | |
pypy/site-packages/astropy/io/votable/tests/vo_test.py:840: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/utils/decorators.py:521: in wrapper | |
return function(*args, **kwargs) | |
pypy/site-packages/astropy/io/votable/table.py:167: in parse | |
config=config, pos=(1, 1)).parse(iterator, config) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <VOTABLE>... 0 tables ...</VOTABLE> | |
iterator = <astropy.utils.xml._iterparser.IterParser object at 0x00000000223fbbe0> | |
config = {'_current_table_number': 0, 'chunk_size': 256, 'columns': None, 'datatype_mapping': {}, ...} | |
def parse(self, iterator, config): | |
config['_current_table_number'] = 0 | |
> for start, tag, data, pos in iterator: | |
E EOFError: Compressed file ended before the end-of-stream marker was reached | |
pypy/site-packages/astropy/io/votable/tree.py:3505: EOFError | |
__________________________ test_initialize_from_FITS ___________________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_initialize_from_FITS0') | |
def test_initialize_from_FITS(tmpdir): | |
ccd_data = create_ccd_data() | |
hdu = fits.PrimaryHDU(ccd_data) | |
hdulist = fits.HDUList([hdu]) | |
filename = tmpdir.join('afile.fits').strpath | |
hdulist.writeto(filename) | |
> cd = CCDData.read(filename, unit=u.electron) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:83: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
________________ test_initialize_from_fits_with_unit_in_header _________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_initialize_from_fits_with0') | |
def test_initialize_from_fits_with_unit_in_header(tmpdir): | |
fake_img = np.zeros([2, 2]) | |
hdu = fits.PrimaryHDU(fake_img) | |
hdu.header['bunit'] = u.adu.to_string() | |
filename = tmpdir.join('afile.fits').strpath | |
hdu.writeto(filename) | |
> ccd = CCDData.read(filename) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:97: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________ test_initialize_from_fits_with_ADU_in_header _________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_initialize_from_fits_with1') | |
def test_initialize_from_fits_with_ADU_in_header(tmpdir): | |
fake_img = np.zeros([2, 2]) | |
hdu = fits.PrimaryHDU(fake_img) | |
hdu.header['bunit'] = 'ADU' | |
filename = tmpdir.join('afile.fits').strpath | |
hdu.writeto(filename) | |
> ccd = CCDData.read(filename) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:112: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________ test_initialize_from_fits_with_invalid_unit_in_header _____________ | |
cls = <class 'astropy.units.format.generic.Generic'> | |
s = 'definetely-not-a-unit', debug = False | |
@classmethod | |
def _do_parse(cls, s, debug=False): | |
try: | |
# This is a short circuit for the case where the string | |
# is just a single unit name | |
> return cls._parse_unit(s, detailed_exception=False) | |
pypy/site-packages/astropy/units/format/generic.py:566: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
cls = <class 'astropy.units.format.generic.Generic'> | |
s = 'definetely-not-a-unit', detailed_exception = False | |
@classmethod | |
def _parse_unit(cls, s, detailed_exception=True): | |
registry = core.get_current_unit_registry().registry | |
if s == '%': | |
return registry['percent'] | |
if not _is_ascii(s): | |
if s[0] == '\N{MICRO SIGN}': | |
s = 'u' + s[1:] | |
if s[-1] == '\N{GREEK CAPITAL LETTER OMEGA}': | |
s = s[:-1] + 'Ohm' | |
elif s[-1] == '\N{LATIN CAPITAL LETTER A WITH RING ABOVE}': | |
s = s[:-1] + 'Angstrom' | |
if s in registry: | |
return registry[s] | |
if detailed_exception: | |
raise ValueError( | |
'{} is not a valid unit. {}'.format( | |
s, did_you_mean(s, registry))) | |
else: | |
> raise ValueError() | |
E ValueError | |
pypy/site-packages/astropy/units/format/generic.py:487: ValueError | |
During handling of the above exception, another exception occurred: | |
cls = <class 'astropy.units.format.generic.Generic'> | |
t = LexToken(UNIT,'definetely',1,0) | |
@classmethod | |
def _get_unit(cls, t): | |
try: | |
> return cls._parse_unit(t.value) | |
pypy/site-packages/astropy/units/format/generic.py:459: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
cls = <class 'astropy.units.format.generic.Generic'>, s = 'definetely' | |
detailed_exception = True | |
@classmethod | |
def _parse_unit(cls, s, detailed_exception=True): | |
registry = core.get_current_unit_registry().registry | |
if s == '%': | |
return registry['percent'] | |
if not _is_ascii(s): | |
if s[0] == '\N{MICRO SIGN}': | |
s = 'u' + s[1:] | |
if s[-1] == '\N{GREEK CAPITAL LETTER OMEGA}': | |
s = s[:-1] + 'Ohm' | |
elif s[-1] == '\N{LATIN CAPITAL LETTER A WITH RING ABOVE}': | |
s = s[:-1] + 'Angstrom' | |
if s in registry: | |
return registry[s] | |
if detailed_exception: | |
raise ValueError( | |
'{} is not a valid unit. {}'.format( | |
> s, did_you_mean(s, registry))) | |
E ValueError: definetely is not a valid unit. | |
pypy/site-packages/astropy/units/format/generic.py:485: ValueError | |
During handling of the above exception, another exception occurred: | |
self = <class 'astropy.units.core.Unit'>, s = 'definetely-not-a-unit' | |
represents = None, format = <class 'astropy.units.format.generic.Generic'> | |
namespace = None, doc = None, parse_strict = 'raise' | |
def __call__(self, s, represents=None, format=None, namespace=None, | |
doc=None, parse_strict='raise'): | |
# Short-circuit if we're already a unit | |
if hasattr(s, '_get_physical_type_id'): | |
return s | |
# turn possible Quantity input for s or represents into a Unit | |
from .quantity import Quantity | |
if isinstance(represents, Quantity): | |
if is_effectively_unity(represents.value): | |
represents = represents.unit | |
else: | |
represents = CompositeUnit(represents.value * | |
represents.unit.scale, | |
bases=represents.unit.bases, | |
powers=represents.unit.powers, | |
_error_check=False) | |
if isinstance(s, Quantity): | |
if is_effectively_unity(s.value): | |
s = s.unit | |
else: | |
s = CompositeUnit(s.value * s.unit.scale, | |
bases=s.unit.bases, | |
powers=s.unit.powers, | |
_error_check=False) | |
# now decide what we really need to do; define derived Unit? | |
if isinstance(represents, UnitBase): | |
# This has the effect of calling the real __new__ and | |
# __init__ on the Unit class. | |
return super().__call__( | |
s, represents, format=format, namespace=namespace, doc=doc) | |
# or interpret a Quantity (now became unit), string or number? | |
if isinstance(s, UnitBase): | |
return s | |
elif isinstance(s, (bytes, str)): | |
if len(s.strip()) == 0: | |
# Return the NULL unit | |
return dimensionless_unscaled | |
if format is None: | |
format = unit_format.Generic | |
f = unit_format.get_format(format) | |
if isinstance(s, bytes): | |
s = s.decode('ascii') | |
try: | |
> return f.parse(s) | |
pypy/site-packages/astropy/units/core.py:1854: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
cls = <class 'astropy.units.format.generic.Generic'> | |
s = 'definetely-not-a-unit', debug = False | |
@classmethod | |
def parse(cls, s, debug=False): | |
if not isinstance(s, str): | |
s = s.decode('ascii') | |
elif not _is_ascii(s): | |
# common normalization of unicode strings to avoid | |
# having to deal with multiple representations of | |
# the same character. This normalizes to "composed" form | |
# and will e.g. convert OHM SIGN to GREEK CAPITAL LETTER OMEGA | |
s = unicodedata.normalize('NFC', s) | |
# Translate some basic unicode items that we'd like to support on | |
# input but are not standard. | |
s = s.translate(cls._translations) | |
# TODO: might the below be better done in the parser/lexer? | |
# Translate superscripts to parenthesized numbers; this ensures | |
# that mixes of superscripts and regular numbers fail. | |
s = cls._regex_superscript.sub(cls._convert_superscript, s) | |
# Translate possible degrees. | |
s = cls._regex_deg.sub(cls._convert_deg, s) | |
> result = cls._do_parse(s, debug=debug) | |
pypy/site-packages/astropy/units/format/generic.py:551: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
cls = <class 'astropy.units.format.generic.Generic'> | |
s = 'definetely-not-a-unit', debug = False | |
@classmethod | |
def _do_parse(cls, s, debug=False): | |
try: | |
# This is a short circuit for the case where the string | |
# is just a single unit name | |
return cls._parse_unit(s, detailed_exception=False) | |
except ValueError as e: | |
try: | |
> return cls._parser.parse(s, lexer=cls._lexer, debug=debug) | |
pypy/site-packages/astropy/units/format/generic.py:569: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.extern.ply.yacc.LRParser object at 0x00007f587b987cc8> | |
input = 'definetely-not-a-unit' | |
lexer = <astropy.extern.ply.lex.Lexer object at 0x00007f587b9866e8> | |
debug = False, tracking = False, tokenfunc = None | |
def parse(self, input=None, lexer=None, debug=False, tracking=False, tokenfunc=None): | |
if debug or yaccdevel: | |
if isinstance(debug, int): | |
debug = PlyLogger(sys.stderr) | |
return self.parsedebug(input, lexer, debug, tracking, tokenfunc) | |
elif tracking: | |
return self.parseopt(input, lexer, debug, tracking, tokenfunc) | |
else: | |
> return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc) | |
pypy/site-packages/astropy/extern/ply/yacc.py:331: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.extern.ply.yacc.LRParser object at 0x00007f587b987cc8> | |
input = 'definetely-not-a-unit' | |
lexer = <astropy.extern.ply.lex.Lexer object at 0x00007f587b9866e8> | |
debug = False, tracking = False, tokenfunc = None | |
def parseopt_notrack(self, input=None, lexer=None, debug=False, tracking=False, tokenfunc=None): | |
#--! parseopt-notrack-start | |
lookahead = None # Current lookahead symbol | |
lookaheadstack = [] # Stack of lookahead symbols | |
actions = self.action # Local reference to action table (to avoid lookup on self.) | |
goto = self.goto # Local reference to goto table (to avoid lookup on self.) | |
prod = self.productions # Local reference to production list (to avoid lookup on self.) | |
defaulted_states = self.defaulted_states # Local reference to defaulted states | |
pslice = YaccProduction(None) # Production object passed to grammar rules | |
errorcount = 0 # Used during error recovery | |
# If no lexer was given, we will try to use the lex module | |
if not lexer: | |
from . import lex | |
lexer = lex.lexer | |
# Set up the lexer and parser objects on pslice | |
pslice.lexer = lexer | |
pslice.parser = self | |
# If input was supplied, pass to lexer | |
if input is not None: | |
lexer.input(input) | |
if tokenfunc is None: | |
# Tokenize function | |
get_token = lexer.token | |
else: | |
get_token = tokenfunc | |
# Set the parser() token method (sometimes used in error recovery) | |
self.token = get_token | |
# Set up the state and symbol stacks | |
statestack = [] # Stack of parsing states | |
self.statestack = statestack | |
symstack = [] # Stack of grammar symbols | |
self.symstack = symstack | |
pslice.stack = symstack # Put in the production | |
errtoken = None # Err token | |
# The start state is assumed to be (0,$end) | |
statestack.append(0) | |
sym = YaccSymbol() | |
sym.type = '$end' | |
symstack.append(sym) | |
state = 0 | |
while True: | |
# Get the next symbol on the input. If a lookahead symbol | |
# is already set, we just use that. Otherwise, we'll pull | |
# the next token off of the lookaheadstack or from the lexer | |
if state not in defaulted_states: | |
if not lookahead: | |
if not lookaheadstack: | |
> lookahead = get_token() # Get the next token | |
pypy/site-packages/astropy/extern/ply/yacc.py:1061: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.extern.ply.lex.Lexer object at 0x00007f587b9866e8> | |
def token(self): | |
# Make local copies of frequently referenced attributes | |
lexpos = self.lexpos | |
lexlen = self.lexlen | |
lexignore = self.lexignore | |
lexdata = self.lexdata | |
while lexpos < lexlen: | |
# This code provides some short-circuit code for whitespace, tabs, and other ignored characters | |
if lexdata[lexpos] in lexignore: | |
lexpos += 1 | |
continue | |
# Look for a regular expression match | |
for lexre, lexindexfunc in self.lexre: | |
m = lexre.match(lexdata, lexpos) | |
if not m: | |
continue | |
# Create a token for return | |
tok = LexToken() | |
tok.value = m.group() | |
tok.lineno = self.lineno | |
tok.lexpos = lexpos | |
i = m.lastindex | |
func, tok.type = lexindexfunc[i] | |
if not func: | |
# If no token type was set, it's an ignored token | |
if tok.type: | |
self.lexpos = m.end() | |
return tok | |
else: | |
lexpos = m.end() | |
break | |
lexpos = m.end() | |
# If token is processed by a function, call it | |
tok.lexer = self # Set additional attributes useful in token rules | |
self.lexmatch = m | |
self.lexpos = lexpos | |
> newtok = func(tok) | |
pypy/site-packages/astropy/extern/ply/lex.py:350: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
t = LexToken(UNIT,'definetely',1,0) | |
def t_UNIT(t): | |
"%|([YZEPTGMkhdcmu\N{MICRO SIGN}npfazy]?'((?!\\d)\\w)+')|((?!\\d)\\w)+" | |
> t.value = cls._get_unit(t) | |
pypy/site-packages/astropy/units/format/generic.py:165: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
cls = <class 'astropy.units.format.generic.Generic'> | |
t = LexToken(UNIT,'definetely',1,0) | |
@classmethod | |
def _get_unit(cls, t): | |
try: | |
return cls._parse_unit(t.value) | |
except ValueError as e: | |
raise ValueError( | |
"At col {}, {}".format( | |
> t.lexpos, str(e))) | |
E ValueError: At col 0, definetely is not a valid unit. | |
pypy/site-packages/astropy/units/format/generic.py:463: ValueError | |
During handling of the above exception, another exception occurred: | |
filename = <_io.FileIO [closed]>, hdu = 0, unit = None | |
hdu_uncertainty = 'UNCERT', hdu_mask = 'MASK', hdu_flags = None | |
key_uncertainty_type = 'UTYPE', kwd = {} | |
unsupport_open_keywords = {'do_not_scale_image_data': 'Image data must be scaled.', 'scale_back': 'Scale information is not preserved.'} | |
key = 'scale_back', msg = 'Scale information is not preserved.' | |
hdus = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000000dd96ad8>] | |
hdr = SIMPLE = T / conforms to FITS standard | |
BITPIX = -64 / arra... | |
BUNIT = 'definetely-not-a-unit' | |
def fits_ccddata_reader(filename, hdu=0, unit=None, hdu_uncertainty='UNCERT', | |
hdu_mask='MASK', hdu_flags=None, | |
key_uncertainty_type='UTYPE', **kwd): | |
""" | |
Generate a CCDData object from a FITS file. | |
Parameters | |
---------- | |
filename : str | |
Name of fits file. | |
hdu : int, optional | |
FITS extension from which CCDData should be initialized. If zero and | |
and no data in the primary extension, it will search for the first | |
extension with data. The header will be added to the primary header. | |
Default is ``0``. | |
unit : `~astropy.units.Unit`, optional | |
Units of the image data. If this argument is provided and there is a | |
unit for the image in the FITS header (the keyword ``BUNIT`` is used | |
as the unit, if present), this argument is used for the unit. | |
Default is ``None``. | |
hdu_uncertainty : str or None, optional | |
FITS extension from which the uncertainty should be initialized. If the | |
extension does not exist the uncertainty of the CCDData is ``None``. | |
Default is ``'UNCERT'``. | |
hdu_mask : str or None, optional | |
FITS extension from which the mask should be initialized. If the | |
extension does not exist the mask of the CCDData is ``None``. | |
Default is ``'MASK'``. | |
hdu_flags : str or None, optional | |
Currently not implemented. | |
Default is ``None``. | |
key_uncertainty_type : str, optional | |
The header key name where the class name of the uncertainty is stored | |
in the hdu of the uncertainty (if any). | |
Default is ``UTYPE``. | |
.. versionadded:: 3.1 | |
kwd : | |
Any additional keyword parameters are passed through to the FITS reader | |
in :mod:`astropy.io.fits`; see Notes for additional discussion. | |
Notes | |
----- | |
FITS files that contained scaled data (e.g. unsigned integer images) will | |
be scaled and the keywords used to manage scaled data in | |
:mod:`astropy.io.fits` are disabled. | |
""" | |
unsupport_open_keywords = { | |
'do_not_scale_image_data': 'Image data must be scaled.', | |
'scale_back': 'Scale information is not preserved.' | |
} | |
for key, msg in unsupport_open_keywords.items(): | |
if key in kwd: | |
prefix = f'unsupported keyword: {key}.' | |
raise TypeError(' '.join([prefix, msg])) | |
with fits.open(filename, **kwd) as hdus: | |
hdr = hdus[hdu].header | |
if hdu_uncertainty is not None and hdu_uncertainty in hdus: | |
unc_hdu = hdus[hdu_uncertainty] | |
stored_unc_name = unc_hdu.header.get(key_uncertainty_type, 'None') | |
# For compatibility reasons the default is standard deviation | |
# uncertainty because files could have been created before the | |
# uncertainty type was stored in the header. | |
unc_type = _unc_name_to_cls.get(stored_unc_name, StdDevUncertainty) | |
uncertainty = unc_type(unc_hdu.data) | |
else: | |
uncertainty = None | |
if hdu_mask is not None and hdu_mask in hdus: | |
# Mask is saved as uint but we want it to be boolean. | |
mask = hdus[hdu_mask].data.astype(np.bool_) | |
else: | |
mask = None | |
if hdu_flags is not None and hdu_flags in hdus: | |
raise NotImplementedError('loading flags is currently not ' | |
'supported.') | |
# search for the first instance with data if | |
# the primary header is empty. | |
if hdu == 0 and hdus[hdu].data is None: | |
for i in range(len(hdus)): | |
if (hdus.info(hdu)[i][3] == 'ImageHDU' and | |
hdus.fileinfo(i)['datSpan'] > 0): | |
hdu = i | |
comb_hdr = hdus[hdu].header.copy() | |
# Add header values from the primary header that aren't | |
# present in the extension header. | |
comb_hdr.extend(hdr, unique=True) | |
hdr = comb_hdr | |
log.info("first HDU with data is extension " | |
"{}.".format(hdu)) | |
break | |
if 'bunit' in hdr: | |
fits_unit_string = hdr['bunit'] | |
# patch to handle FITS files using ADU for the unit instead of the | |
# standard version of 'adu' | |
if fits_unit_string.strip().lower() == 'adu': | |
fits_unit_string = fits_unit_string.lower() | |
else: | |
fits_unit_string = None | |
if fits_unit_string: | |
if unit is None: | |
# Convert the BUNIT header keyword to a unit and if that's not | |
# possible raise a meaningful error message. | |
try: | |
kifus = CCDData.known_invalid_fits_unit_strings | |
if fits_unit_string in kifus: | |
fits_unit_string = kifus[fits_unit_string] | |
> fits_unit_string = u.Unit(fits_unit_string) | |
pypy/site-packages/astropy/nddata/ccddata.py:648: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <class 'astropy.units.core.Unit'>, s = 'definetely-not-a-unit' | |
represents = None, format = <class 'astropy.units.format.generic.Generic'> | |
namespace = None, doc = None, parse_strict = 'raise' | |
def __call__(self, s, represents=None, format=None, namespace=None, | |
doc=None, parse_strict='raise'): | |
# Short-circuit if we're already a unit | |
if hasattr(s, '_get_physical_type_id'): | |
return s | |
# turn possible Quantity input for s or represents into a Unit | |
from .quantity import Quantity | |
if isinstance(represents, Quantity): | |
if is_effectively_unity(represents.value): | |
represents = represents.unit | |
else: | |
represents = CompositeUnit(represents.value * | |
represents.unit.scale, | |
bases=represents.unit.bases, | |
powers=represents.unit.powers, | |
_error_check=False) | |
if isinstance(s, Quantity): | |
if is_effectively_unity(s.value): | |
s = s.unit | |
else: | |
s = CompositeUnit(s.value * s.unit.scale, | |
bases=s.unit.bases, | |
powers=s.unit.powers, | |
_error_check=False) | |
# now decide what we really need to do; define derived Unit? | |
if isinstance(represents, UnitBase): | |
# This has the effect of calling the real __new__ and | |
# __init__ on the Unit class. | |
return super().__call__( | |
s, represents, format=format, namespace=namespace, doc=doc) | |
# or interpret a Quantity (now became unit), string or number? | |
if isinstance(s, UnitBase): | |
return s | |
elif isinstance(s, (bytes, str)): | |
if len(s.strip()) == 0: | |
# Return the NULL unit | |
return dimensionless_unscaled | |
if format is None: | |
format = unit_format.Generic | |
f = unit_format.get_format(format) | |
if isinstance(s, bytes): | |
s = s.decode('ascii') | |
try: | |
return f.parse(s) | |
except Exception as e: | |
if parse_strict == 'silent': | |
pass | |
else: | |
# Deliberately not issubclass here. Subclasses | |
# should use their name. | |
if f is not unit_format.Generic: | |
format_clause = f.name + ' ' | |
else: | |
format_clause = '' | |
msg = ("'{}' did not parse as {}unit: {} " | |
"If this is meant to be a custom unit, " | |
"define it with 'u.def_unit'. To have it " | |
"recognized inside a file reader or other code, " | |
"enable it with 'u.add_enabled_units'. " | |
"For details, see " | |
"http://docs.astropy.org/en/latest/units/combining_and_defining.html" | |
.format(s, format_clause, str(e))) | |
if parse_strict == 'raise': | |
> raise ValueError(msg) | |
E ValueError: 'definetely-not-a-unit' did not parse as unit: At col 0, definetely is not a valid unit. If this is meant to be a custom unit, define it with 'u.def_unit'. To have it recognized inside a file reader or other code, enable it with 'u.add_enabled_units'. For details, see http://docs.astropy.org/en/latest/units/combining_and_defining.html | |
pypy/site-packages/astropy/units/core.py:1874: ValueError | |
During handling of the above exception, another exception occurred: | |
filename = <_io.FileIO [closed]>, hdu = 0, unit = None | |
hdu_uncertainty = 'UNCERT', hdu_mask = 'MASK', hdu_flags = None | |
key_uncertainty_type = 'UTYPE', kwd = {} | |
unsupport_open_keywords = {'do_not_scale_image_data': 'Image data must be scaled.', 'scale_back': 'Scale information is not preserved.'} | |
key = 'scale_back', msg = 'Scale information is not preserved.' | |
hdus = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000000dd96ad8>] | |
hdr = SIMPLE = T / conforms to FITS standard | |
BITPIX = -64 / arra... | |
BUNIT = 'definetely-not-a-unit' | |
def fits_ccddata_reader(filename, hdu=0, unit=None, hdu_uncertainty='UNCERT', | |
hdu_mask='MASK', hdu_flags=None, | |
key_uncertainty_type='UTYPE', **kwd): | |
""" | |
Generate a CCDData object from a FITS file. | |
Parameters | |
---------- | |
filename : str | |
Name of fits file. | |
hdu : int, optional | |
FITS extension from which CCDData should be initialized. If zero and | |
and no data in the primary extension, it will search for the first | |
extension with data. The header will be added to the primary header. | |
Default is ``0``. | |
unit : `~astropy.units.Unit`, optional | |
Units of the image data. If this argument is provided and there is a | |
unit for the image in the FITS header (the keyword ``BUNIT`` is used | |
as the unit, if present), this argument is used for the unit. | |
Default is ``None``. | |
hdu_uncertainty : str or None, optional | |
FITS extension from which the uncertainty should be initialized. If the | |
extension does not exist the uncertainty of the CCDData is ``None``. | |
Default is ``'UNCERT'``. | |
hdu_mask : str or None, optional | |
FITS extension from which the mask should be initialized. If the | |
extension does not exist the mask of the CCDData is ``None``. | |
Default is ``'MASK'``. | |
hdu_flags : str or None, optional | |
Currently not implemented. | |
Default is ``None``. | |
key_uncertainty_type : str, optional | |
The header key name where the class name of the uncertainty is stored | |
in the hdu of the uncertainty (if any). | |
Default is ``UTYPE``. | |
.. versionadded:: 3.1 | |
kwd : | |
Any additional keyword parameters are passed through to the FITS reader | |
in :mod:`astropy.io.fits`; see Notes for additional discussion. | |
Notes | |
----- | |
FITS files that contained scaled data (e.g. unsigned integer images) will | |
be scaled and the keywords used to manage scaled data in | |
:mod:`astropy.io.fits` are disabled. | |
""" | |
unsupport_open_keywords = { | |
'do_not_scale_image_data': 'Image data must be scaled.', | |
'scale_back': 'Scale information is not preserved.' | |
} | |
for key, msg in unsupport_open_keywords.items(): | |
if key in kwd: | |
prefix = f'unsupported keyword: {key}.' | |
raise TypeError(' '.join([prefix, msg])) | |
with fits.open(filename, **kwd) as hdus: | |
hdr = hdus[hdu].header | |
if hdu_uncertainty is not None and hdu_uncertainty in hdus: | |
unc_hdu = hdus[hdu_uncertainty] | |
stored_unc_name = unc_hdu.header.get(key_uncertainty_type, 'None') | |
# For compatibility reasons the default is standard deviation | |
# uncertainty because files could have been created before the | |
# uncertainty type was stored in the header. | |
unc_type = _unc_name_to_cls.get(stored_unc_name, StdDevUncertainty) | |
uncertainty = unc_type(unc_hdu.data) | |
else: | |
uncertainty = None | |
if hdu_mask is not None and hdu_mask in hdus: | |
# Mask is saved as uint but we want it to be boolean. | |
mask = hdus[hdu_mask].data.astype(np.bool_) | |
else: | |
mask = None | |
if hdu_flags is not None and hdu_flags in hdus: | |
raise NotImplementedError('loading flags is currently not ' | |
'supported.') | |
# search for the first instance with data if | |
# the primary header is empty. | |
if hdu == 0 and hdus[hdu].data is None: | |
for i in range(len(hdus)): | |
if (hdus.info(hdu)[i][3] == 'ImageHDU' and | |
hdus.fileinfo(i)['datSpan'] > 0): | |
hdu = i | |
comb_hdr = hdus[hdu].header.copy() | |
# Add header values from the primary header that aren't | |
# present in the extension header. | |
comb_hdr.extend(hdr, unique=True) | |
hdr = comb_hdr | |
log.info("first HDU with data is extension " | |
"{}.".format(hdu)) | |
break | |
if 'bunit' in hdr: | |
fits_unit_string = hdr['bunit'] | |
# patch to handle FITS files using ADU for the unit instead of the | |
# standard version of 'adu' | |
if fits_unit_string.strip().lower() == 'adu': | |
fits_unit_string = fits_unit_string.lower() | |
else: | |
fits_unit_string = None | |
if fits_unit_string: | |
if unit is None: | |
# Convert the BUNIT header keyword to a unit and if that's not | |
# possible raise a meaningful error message. | |
try: | |
kifus = CCDData.known_invalid_fits_unit_strings | |
if fits_unit_string in kifus: | |
fits_unit_string = kifus[fits_unit_string] | |
fits_unit_string = u.Unit(fits_unit_string) | |
except ValueError: | |
raise ValueError( | |
'The Header value for the key BUNIT ({}) cannot be ' | |
'interpreted as valid unit. To successfully read the ' | |
'file as CCDData you can pass in a valid `unit` ' | |
'argument explicitly or change the header of the FITS ' | |
'file before reading it.' | |
> .format(fits_unit_string)) | |
E ValueError: The Header value for the key BUNIT (definetely-not-a-unit) cannot be interpreted as valid unit. To successfully read the file as CCDData you can pass in a valid `unit` argument explicitly or change the header of the FITS file before reading it. | |
pypy/site-packages/astropy/nddata/ccddata.py:656: ValueError | |
During handling of the above exception, another exception occurred: | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_initialize_from_fits_with2') | |
def test_initialize_from_fits_with_invalid_unit_in_header(tmpdir): | |
hdu = fits.PrimaryHDU(np.ones((2, 2))) | |
hdu.header['bunit'] = 'definetely-not-a-unit' | |
filename = tmpdir.join('afile.fits').strpath | |
hdu.writeto(filename) | |
with pytest.raises(ValueError): | |
> CCDData.read(filename) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:123: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______ test_initialize_from_fits_with_technically_invalid_but_not_really _______ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_initialize_from_fits_with3') | |
def test_initialize_from_fits_with_technically_invalid_but_not_really(tmpdir): | |
hdu = fits.PrimaryHDU(np.ones((2, 2))) | |
hdu.header['bunit'] = 'ELECTRONS/S' | |
filename = tmpdir.join('afile.fits').strpath | |
hdu.writeto(filename) | |
> ccd = CCDData.read(filename) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:131: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________ test_initialize_from_fits_with_data_in_different_extension __________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_initialize_from_fits_with4') | |
def test_initialize_from_fits_with_data_in_different_extension(tmpdir): | |
fake_img = np.arange(4).reshape(2, 2) | |
hdu1 = fits.PrimaryHDU() | |
hdu2 = fits.ImageHDU(fake_img) | |
hdus = fits.HDUList([hdu1, hdu2]) | |
filename = tmpdir.join('afile.fits').strpath | |
hdus.writeto(filename) | |
with catch_warnings(FITSFixedWarning) as w: | |
> ccd = CCDData.read(filename, unit='adu') | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:143: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
----------------------------- Captured stdout call ----------------------------- | |
INFO: first HDU with data is extension 1. [astropy.nddata.ccddata] | |
------------------------------ Captured log call ------------------------------- | |
INFO astropy:ccddata.py:628 first HDU with data is extension 1. | |
___________________ test_initialize_from_fits_with_extension ___________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_initialize_from_fits_with5') | |
def test_initialize_from_fits_with_extension(tmpdir): | |
fake_img1 = np.zeros([2, 2]) | |
fake_img2 = np.arange(4).reshape(2, 2) | |
hdu0 = fits.PrimaryHDU() | |
hdu1 = fits.ImageHDU(fake_img1) | |
hdu2 = fits.ImageHDU(fake_img2) | |
hdus = fits.HDUList([hdu0, hdu1, hdu2]) | |
filename = tmpdir.join('afile.fits').strpath | |
hdus.writeto(filename) | |
> ccd = CCDData.read(filename, hdu=2, unit='adu') | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:160: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________________________ test_ccddata_writer ______________________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_ccddata_writer0') | |
def test_ccddata_writer(tmpdir): | |
ccd_data = create_ccd_data() | |
filename = tmpdir.join('test.fits').strpath | |
ccd_data.write(filename) | |
> ccd_disk = CCDData.read(filename, unit=ccd_data.unit) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:192: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
----------------------------- Captured stdout call ----------------------------- | |
INFO: using the unit adu passed to the FITS reader instead of the unit adu in the FITS file. [astropy.nddata.ccddata] | |
------------------------------ Captured log call ------------------------------- | |
INFO astropy:ccddata.py:660 using the unit adu passed to the FITS reader instead of the unit adu in the FITS file. | |
_________________________________ test_fromMEF _________________________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_fromMEF0') | |
def test_fromMEF(tmpdir): | |
ccd_data = create_ccd_data() | |
hdu = fits.PrimaryHDU(ccd_data) | |
hdu2 = fits.PrimaryHDU(2 * ccd_data.data) | |
hdulist = fits.HDUList(hdu) | |
hdulist.append(hdu2) | |
filename = tmpdir.join('afile.fits').strpath | |
hdulist.writeto(filename) | |
# by default, we reading from the first extension | |
> cd = CCDData.read(filename, unit=u.electron) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:220: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
______________ test_history_preserved_if_metadata_is_fits_header _______________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_history_preserved_if_meta0') | |
def test_history_preserved_if_metadata_is_fits_header(tmpdir): | |
fake_img = np.zeros([2, 2]) | |
hdu = fits.PrimaryHDU(fake_img) | |
hdu.header['history'] = 'one' | |
hdu.header['history'] = 'two' | |
hdu.header['history'] = 'three' | |
assert len(hdu.header['history']) == 3 | |
tmp_file = tmpdir.join('temp.fits').strpath | |
hdu.writeto(tmp_file) | |
> ccd_read = CCDData.read(tmp_file, unit="adu") | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:571: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________ test_infol_logged_if_unit_in_fits_header ___________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_infol_logged_if_unit_in_f0') | |
def test_infol_logged_if_unit_in_fits_header(tmpdir): | |
ccd_data = create_ccd_data() | |
tmpfile = tmpdir.join('temp.fits') | |
ccd_data.write(tmpfile.strpath) | |
log.setLevel('INFO') | |
explicit_unit_name = "photon" | |
with log.log_to_list() as log_list: | |
> ccd_from_disk = CCDData.read(tmpfile.strpath, unit=explicit_unit_name) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:582: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
----------------------------- Captured stdout call ----------------------------- | |
INFO: using the unit photon passed to the FITS reader instead of the unit adu in the FITS file. [astropy.nddata.ccddata] | |
------------------------------ Captured log call ------------------------------- | |
INFO astropy:ccddata.py:660 using the unit photon passed to the FITS reader instead of the unit adu in the FITS file. | |
______________________________ test_wcs_attribute ______________________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_wcs_attribute0') | |
def test_wcs_attribute(tmpdir): | |
""" | |
Check that WCS attribute gets added to header, and that if a CCDData | |
object is created from a FITS file with a header, and the WCS attribute | |
is modified, then the CCDData object is turned back into an hdu, the | |
WCS object overwrites the old WCS information in the header. | |
""" | |
ccd_data = create_ccd_data() | |
tmpfile = tmpdir.join('temp.fits') | |
# This wcs example is taken from the astropy.wcs docs. | |
wcs = WCS(naxis=2) | |
wcs.wcs.crpix = np.array(ccd_data.shape) / 2 | |
wcs.wcs.cdelt = np.array([-0.066667, 0.066667]) | |
wcs.wcs.crval = [0, -90] | |
wcs.wcs.ctype = ["RA---AIR", "DEC--AIR"] | |
wcs.wcs.set_pv([(2, 1, 45.0)]) | |
ccd_data.header = ccd_data.to_hdu()[0].header | |
ccd_data.header.extend(wcs.to_header(), useblanks=False) | |
ccd_data.write(tmpfile.strpath) | |
# Get the header length after it has been extended by the WCS keywords | |
original_header_length = len(ccd_data.header) | |
> ccd_new = CCDData.read(tmpfile.strpath) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:609: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________________ test_wcs_keywords_removed_from_header _____________________ | |
def test_wcs_keywords_removed_from_header(): | |
""" | |
Test, for the file included with the nddata tests, that WCS keywords are | |
properly removed from header. | |
""" | |
from astropy.nddata.ccddata import _KEEP_THESE_KEYWORDS_IN_HEADER | |
keepers = set(_KEEP_THESE_KEYWORDS_IN_HEADER) | |
data_file = get_pkg_data_filename('data/sip-wcs.fits') | |
> ccd = CCDData.read(data_file) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:655: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__________________ test_wcs_SIP_coefficient_keywords_removed ___________________ | |
def test_wcs_SIP_coefficient_keywords_removed(): | |
# If SIP polynomials are present, check that no more polynomial | |
# coefficients remain in the header. See #8598 | |
# The SIP paper is ambiguous as to whether keywords like | |
# A_0_0 can appear in the header for a 2nd order or higher | |
# polynomial. The paper clearly says that the corrections | |
# are only for quadratic or higher order, so A_0_0 and the like | |
# should be zero if they are present, but they apparently can be | |
# there (or at least astrometry.net produces them). | |
# astropy WCS does not write those coefficients, so they were | |
# not being removed from the header even though they are WCS-related. | |
data_file = get_pkg_data_filename('data/sip-wcs.fits') | |
test_keys = ['A_0_0', 'B_0_1'] | |
# Make sure the keywords added to this file for testing are there | |
with fits.open(data_file) as hdu: | |
for key in test_keys: | |
assert key in hdu[0].header | |
> ccd = CCDData.read(data_file) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:690: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________________ test_read_wcs_not_creatable __________________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_read_wcs_not_creatable0') | |
def test_read_wcs_not_creatable(tmpdir): | |
# The following Header can't be converted to a WCS object. See also #6499. | |
hdr_txt_example_WCS = textwrap.dedent(''' | |
SIMPLE = T / Fits standard | |
BITPIX = 16 / Bits per pixel | |
NAXIS = 2 / Number of axes | |
NAXIS1 = 1104 / Axis length | |
NAXIS2 = 4241 / Axis length | |
CRVAL1 = 164.98110962 / Physical value of the reference pixel X | |
CRVAL2 = 44.34089279 / Physical value of the reference pixel Y | |
CRPIX1 = -34.0 / Reference pixel in X (pixel) | |
CRPIX2 = 2041.0 / Reference pixel in Y (pixel) | |
CDELT1 = 0.10380000 / X Scale projected on detector (#/pix) | |
CDELT2 = 0.10380000 / Y Scale projected on detector (#/pix) | |
CTYPE1 = 'RA---TAN' / Pixel coordinate system | |
CTYPE2 = 'WAVELENGTH' / Pixel coordinate system | |
CUNIT1 = 'degree ' / Units used in both CRVAL1 and CDELT1 | |
CUNIT2 = 'nm ' / Units used in both CRVAL2 and CDELT2 | |
CD1_1 = 0.20760000 / Pixel Coordinate translation matrix | |
CD1_2 = 0.00000000 / Pixel Coordinate translation matrix | |
CD2_1 = 0.00000000 / Pixel Coordinate translation matrix | |
CD2_2 = 0.10380000 / Pixel Coordinate translation matrix | |
C2YPE1 = 'RA---TAN' / Pixel coordinate system | |
C2YPE2 = 'DEC--TAN' / Pixel coordinate system | |
C2NIT1 = 'degree ' / Units used in both C2VAL1 and C2ELT1 | |
C2NIT2 = 'degree ' / Units used in both C2VAL2 and C2ELT2 | |
RADECSYS= 'FK5 ' / The equatorial coordinate system | |
''') | |
with catch_warnings(FITSFixedWarning): | |
hdr = fits.Header.fromstring(hdr_txt_example_WCS, sep='\n') | |
hdul = fits.HDUList([fits.PrimaryHDU(np.ones((4241, 1104)), header=hdr)]) | |
filename = tmpdir.join('afile.fits').strpath | |
hdul.writeto(filename) | |
# The hdr cannot be converted to a WCS object because of an | |
# InconsistentAxisTypesError but it should still open the file | |
> ccd = CCDData.read(filename, unit='adu') | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:790: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
----------------------------- Captured stdout call ----------------------------- | |
INFO: An exception happened while extracting WCS informations from the Header. | |
InconsistentAxisTypesError: ERROR 4 in wcs_types() at line 2707 of file cextern/wcslib/C/wcs.c: | |
Unmatched celestial axes. | |
[astropy.nddata.ccddata] | |
------------------------------ Captured log call ------------------------------- | |
INFO astropy:ccddata.py:480 An exception happened while extracting WCS informations from the Header. | |
InconsistentAxisTypesError: ERROR 4 in wcs_types() at line 2707 of file cextern/wcslib/C/wcs.c: | |
Unmatched celestial axes. | |
____________________________ test_wcs_sip_handling _____________________________ | |
def test_wcs_sip_handling(): | |
""" | |
Check whether the ctypes RA---TAN-SIP and DEC--TAN-SIP survive | |
a roundtrip unchanged. | |
""" | |
data_file = get_pkg_data_filename('data/sip-wcs.fits') | |
def check_wcs_ctypes(header): | |
expected_wcs_ctypes = { | |
'CTYPE1': 'RA---TAN-SIP', | |
'CTYPE2': 'DEC--TAN-SIP' | |
} | |
return [header[k] == v for k, v in expected_wcs_ctypes.items()] | |
> ccd_original = CCDData.read(data_file) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:836: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_______________ test_write_read_multiextensionfits_mask_default ________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_write_read_multiextension0') | |
def test_write_read_multiextensionfits_mask_default(tmpdir): | |
# Test that if a mask is present the mask is saved and loaded by default. | |
ccd_data = create_ccd_data() | |
ccd_data.mask = ccd_data.data > 10 | |
filename = tmpdir.join('afile.fits').strpath | |
ccd_data.write(filename) | |
> ccd_after = CCDData.read(filename) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:875: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
__ test_write_read_multiextensionfits_uncertainty_default[StdDevUncertainty] ___ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_write_read_multiextension1') | |
uncertainty_type = <class 'astropy.nddata.nduncertainty.StdDevUncertainty'> | |
@pytest.mark.parametrize( | |
'uncertainty_type', | |
[StdDevUncertainty, VarianceUncertainty, InverseVariance]) | |
def test_write_read_multiextensionfits_uncertainty_default( | |
tmpdir, uncertainty_type): | |
# Test that if a uncertainty is present it is saved and loaded by default. | |
ccd_data = create_ccd_data() | |
ccd_data.uncertainty = uncertainty_type(ccd_data.data * 10) | |
filename = tmpdir.join('afile.fits').strpath | |
ccd_data.write(filename) | |
> ccd_after = CCDData.read(filename) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:890: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_ test_write_read_multiextensionfits_uncertainty_default[VarianceUncertainty] __ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_write_read_multiextension2') | |
uncertainty_type = <class 'astropy.nddata.nduncertainty.VarianceUncertainty'> | |
@pytest.mark.parametrize( | |
'uncertainty_type', | |
[StdDevUncertainty, VarianceUncertainty, InverseVariance]) | |
def test_write_read_multiextensionfits_uncertainty_default( | |
tmpdir, uncertainty_type): | |
# Test that if a uncertainty is present it is saved and loaded by default. | |
ccd_data = create_ccd_data() | |
ccd_data.uncertainty = uncertainty_type(ccd_data.data * 10) | |
filename = tmpdir.join('afile.fits').strpath | |
ccd_data.write(filename) | |
> ccd_after = CCDData.read(filename) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:890: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___ test_write_read_multiextensionfits_uncertainty_default[InverseVariance] ____ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_write_read_multiextension3') | |
uncertainty_type = <class 'astropy.nddata.nduncertainty.InverseVariance'> | |
@pytest.mark.parametrize( | |
'uncertainty_type', | |
[StdDevUncertainty, VarianceUncertainty, InverseVariance]) | |
def test_write_read_multiextensionfits_uncertainty_default( | |
tmpdir, uncertainty_type): | |
# Test that if a uncertainty is present it is saved and loaded by default. | |
ccd_data = create_ccd_data() | |
ccd_data.uncertainty = uncertainty_type(ccd_data.data * 10) | |
filename = tmpdir.join('afile.fits').strpath | |
ccd_data.write(filename) | |
> ccd_after = CCDData.read(filename) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:890: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_ test_write_read_multiextensionfits_uncertainty_different_uncertainty_key[StdDevUncertainty] _ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_write_read_multiextension4') | |
uncertainty_type = <class 'astropy.nddata.nduncertainty.StdDevUncertainty'> | |
@pytest.mark.parametrize( | |
'uncertainty_type', | |
[StdDevUncertainty, VarianceUncertainty, InverseVariance]) | |
def test_write_read_multiextensionfits_uncertainty_different_uncertainty_key( | |
tmpdir, uncertainty_type): | |
# Test that if a uncertainty is present it is saved and loaded by default. | |
ccd_data = create_ccd_data() | |
ccd_data.uncertainty = uncertainty_type(ccd_data.data * 10) | |
filename = tmpdir.join('afile.fits').strpath | |
ccd_data.write(filename, key_uncertainty_type='Blah') | |
> ccd_after = CCDData.read(filename, key_uncertainty_type='Blah') | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:907: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_ test_write_read_multiextensionfits_uncertainty_different_uncertainty_key[VarianceUncertainty] _ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_write_read_multiextension5') | |
uncertainty_type = <class 'astropy.nddata.nduncertainty.VarianceUncertainty'> | |
@pytest.mark.parametrize( | |
'uncertainty_type', | |
[StdDevUncertainty, VarianceUncertainty, InverseVariance]) | |
def test_write_read_multiextensionfits_uncertainty_different_uncertainty_key( | |
tmpdir, uncertainty_type): | |
# Test that if a uncertainty is present it is saved and loaded by default. | |
ccd_data = create_ccd_data() | |
ccd_data.uncertainty = uncertainty_type(ccd_data.data * 10) | |
filename = tmpdir.join('afile.fits').strpath | |
ccd_data.write(filename, key_uncertainty_type='Blah') | |
> ccd_after = CCDData.read(filename, key_uncertainty_type='Blah') | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:907: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_ test_write_read_multiextensionfits_uncertainty_different_uncertainty_key[InverseVariance] _ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_write_read_multiextension6') | |
uncertainty_type = <class 'astropy.nddata.nduncertainty.InverseVariance'> | |
@pytest.mark.parametrize( | |
'uncertainty_type', | |
[StdDevUncertainty, VarianceUncertainty, InverseVariance]) | |
def test_write_read_multiextensionfits_uncertainty_different_uncertainty_key( | |
tmpdir, uncertainty_type): | |
# Test that if a uncertainty is present it is saved and loaded by default. | |
ccd_data = create_ccd_data() | |
ccd_data.uncertainty = uncertainty_type(ccd_data.data * 10) | |
filename = tmpdir.join('afile.fits').strpath | |
ccd_data.write(filename, key_uncertainty_type='Blah') | |
> ccd_after = CCDData.read(filename, key_uncertainty_type='Blah') | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:907: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________________ test_write_read_multiextensionfits_not ____________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_write_read_multiextension7') | |
def test_write_read_multiextensionfits_not(tmpdir): | |
# Test that writing mask and uncertainty can be disabled | |
ccd_data = create_ccd_data() | |
ccd_data.mask = ccd_data.data > 10 | |
ccd_data.uncertainty = StdDevUncertainty(ccd_data.data * 10) | |
filename = tmpdir.join('afile.fits').strpath | |
ccd_data.write(filename, hdu_mask=None, hdu_uncertainty=None) | |
> ccd_after = CCDData.read(filename) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:921: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_____________ test_write_read_multiextensionfits_custom_ext_names ______________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_write_read_multiextension8') | |
def test_write_read_multiextensionfits_custom_ext_names(tmpdir): | |
# Test writing mask, uncertainty in another extension than default | |
ccd_data = create_ccd_data() | |
ccd_data.mask = ccd_data.data > 10 | |
ccd_data.uncertainty = StdDevUncertainty(ccd_data.data * 10) | |
filename = tmpdir.join('afile.fits').strpath | |
ccd_data.write(filename, hdu_mask='Fun', hdu_uncertainty='NoFun') | |
# Try reading with defaults extension names | |
> ccd_after = CCDData.read(filename) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:935: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________________ test_read_old_style_multiextensionfits ____________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_read_old_style_multiexten0') | |
def test_read_old_style_multiextensionfits(tmpdir): | |
# Regression test for https://github.com/astropy/ccdproc/issues/664 | |
# | |
# Prior to astropy 3.1 there was no uncertainty type saved | |
# in the multiextension fits files generated by CCDData | |
# because the uncertainty had to be StandardDevUncertainty. | |
# | |
# Current version should be able to read those in. | |
# | |
size = 4 | |
# Value of the variables below are not important to the test. | |
data = np.zeros([size, size]) | |
mask = data > 0.9 | |
uncert = np.sqrt(data) | |
ccd = CCDData(data=data, mask=mask, uncertainty=uncert, unit='adu') | |
# We'll create the file manually to ensure we have the | |
# right extension names and no uncertainty type. | |
hdulist = ccd.to_hdu() | |
del hdulist[2].header['UTYPE'] | |
file_name = tmpdir.join('old_ccddata_mef.fits').strpath | |
hdulist.writeto(file_name) | |
> ccd = CCDData.read(file_name) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:971: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
----------------------------- Captured stdout call ----------------------------- | |
INFO: array provided for uncertainty; assuming it is a StdDevUncertainty. [astropy.nddata.ccddata] | |
------------------------------ Captured log call ------------------------------- | |
INFO astropy:ccddata.py:265 array provided for uncertainty; assuming it is a StdDevUncertainty. | |
_________________ test_recognized_fits_formats_for_read_write __________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_recognized_fits_formats_f0') | |
def test_recognized_fits_formats_for_read_write(tmpdir): | |
# These are the extensions that are supposed to be supported. | |
ccd_data = create_ccd_data() | |
supported_extensions = ['fit', 'fits', 'fts'] | |
for ext in supported_extensions: | |
path = tmpdir.join(f"test.{ext}") | |
ccd_data.write(path.strpath) | |
> from_disk = CCDData.read(path.strpath) | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:991: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________________________ test_read_returns_image ____________________________ | |
tmpdir = local('/tmp/pytest-of-tom/pytest-1/test_read_returns_image0') | |
def test_read_returns_image(tmpdir): | |
# Test if CCData.read returns a image when reading a fits file containing | |
# a table and image, in that order. | |
tbl = Table(np.ones(10).reshape(5, 2)) | |
img = np.ones((5, 5)) | |
hdul = fits.HDUList(hdus=[fits.PrimaryHDU(), fits.TableHDU(tbl.as_array()), | |
fits.ImageHDU(img)]) | |
filename = tmpdir.join('table_image.fits').strpath | |
hdul.writeto(filename) | |
> ccd = CCDData.read(filename, unit='adu') | |
pypy/site-packages/astropy/nddata/tests/test_ccddata.py:1021: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/nddata/mixins/ndio.py:56: in __call__ | |
return registry.read(self._cls, *args, **kwargs) | |
pypy/site-packages/astropy/io/registry.py:523: in read | |
data = reader(*args, **kwargs) | |
pypy/site-packages/astropy/nddata/ccddata.py:665: in fits_ccddata_reader | |
mask=mask, uncertainty=uncertainty, wcs=wcs) | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
----------------------------- Captured stdout call ----------------------------- | |
INFO: first HDU with data is extension 2. [astropy.nddata.ccddata] | |
------------------------------ Captured log call ------------------------------- | |
INFO astropy:ccddata.py:628 first HDU with data is extension 2. | |
_________________________ test_pickle_uncertainty_only _________________________ | |
def test_pickle_uncertainty_only(): | |
ndd = NDData(np.ones(3), | |
uncertainty=StdDevUncertainty(np.ones(5), unit=u.m), | |
unit=u.m) | |
uncertainty_dumped = pickle.dumps(ndd.uncertainty) | |
uncertainty_restored = pickle.loads(uncertainty_dumped) | |
np.testing.assert_array_equal(ndd.uncertainty.array, | |
uncertainty_restored.array) | |
assert ndd.uncertainty.unit == uncertainty_restored.unit | |
# Even though it has a parent there is no one that references the parent | |
# after unpickling so the weakref "dies" immediately after unpickling | |
# finishes. | |
> assert uncertainty_restored.parent_nddata is None | |
E assert NDData([1., 1., 1.]) is None | |
E + where NDData([1., 1., 1.]) = StdDevUncertainty([1., 1., 1., 1., 1.]).parent_nddata | |
pypy/site-packages/astropy/nddata/tests/test_nddata.py:386: AssertionError | |
______________ TestIndex.test_index_modes[unmasked-main_col0-BST] ______________ | |
self = <astropy.table.tests.test_index.TestIndex object at 0x000000000fdcd7f8> | |
main_col = [1, 2, 3, 4, 5] | |
table_types = <astropy.table.tests.conftest.table_types.<locals>.TableTypes object at 0x000000000fdcd948> | |
engine = <class 'astropy.table.bst.BST'> | |
def test_index_modes(self, main_col, table_types, engine): | |
self._setup(main_col, table_types) | |
t = self.t | |
t.add_index('a', engine=engine) | |
# first, no special mode | |
assert len(t[[1, 3]].indices) == 1 | |
assert len(t[::-1].indices) == 1 | |
assert len(self._table_type(t).indices) == 1 | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t2 = t.copy() | |
# non-copy mode | |
with t.index_mode('discard_on_copy'): | |
assert len(t[[1, 3]].indices) == 0 | |
assert len(t[::-1].indices) == 0 | |
assert len(self._table_type(t).indices) == 0 | |
assert len(t2.copy().indices) == 1 # mode should only affect t | |
# make sure non-copy mode is exited correctly | |
assert len(t[[1, 3]].indices) == 1 | |
if not self.mutable: | |
return | |
# non-modify mode | |
with t.index_mode('freeze'): | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t['a'][0] = 6 | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t.add_row((2, 1.5, '12')) | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t.remove_rows([1, 3]) | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
assert_col_equal(t['a'], [6, 3, 5, 2]) | |
# mode should only affect t | |
assert np.all(t2.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t2['a'][0] = 6 | |
assert np.all(t2.indices[0].sorted_data() == [1, 2, 3, 4, 0]) | |
# make sure non-modify mode is exited correctly | |
assert np.all(t.indices[0].sorted_data() == [3, 1, 2, 0]) | |
if isinstance(t['a'], BaseColumn): | |
assert len(t['a'][::-1].info.indices) == 0 | |
with t.index_mode('copy_on_getitem'): | |
> assert len(t['a'][[1, 2]].info.indices) == 1 | |
E AssertionError: assert 0 == 1 | |
E + where 0 = len([]) | |
E + where [] = name = a\ndtype = int64\nclass = Column\nn_bad = 0\nlength = 2\n.indices | |
E + where name = a\ndtype = int64\nclass = Column\nn_bad = 0\nlength = 2\n = <Column name='a' dtype='int64' length=2>\n3\n5.info | |
pypy/site-packages/astropy/table/tests/test_index.py:366: AssertionError | |
__________ TestIndex.test_index_modes[unmasked-main_col0-SortedArray] __________ | |
self = <astropy.table.tests.test_index.TestIndex object at 0x0000000011cc10f8> | |
main_col = [1, 2, 3, 4, 5] | |
table_types = <astropy.table.tests.conftest.table_types.<locals>.TableTypes object at 0x0000000011cc0fe0> | |
engine = <class 'astropy.table.sorted_array.SortedArray'> | |
def test_index_modes(self, main_col, table_types, engine): | |
self._setup(main_col, table_types) | |
t = self.t | |
t.add_index('a', engine=engine) | |
# first, no special mode | |
assert len(t[[1, 3]].indices) == 1 | |
assert len(t[::-1].indices) == 1 | |
assert len(self._table_type(t).indices) == 1 | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t2 = t.copy() | |
# non-copy mode | |
with t.index_mode('discard_on_copy'): | |
assert len(t[[1, 3]].indices) == 0 | |
assert len(t[::-1].indices) == 0 | |
assert len(self._table_type(t).indices) == 0 | |
assert len(t2.copy().indices) == 1 # mode should only affect t | |
# make sure non-copy mode is exited correctly | |
assert len(t[[1, 3]].indices) == 1 | |
if not self.mutable: | |
return | |
# non-modify mode | |
with t.index_mode('freeze'): | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t['a'][0] = 6 | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t.add_row((2, 1.5, '12')) | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t.remove_rows([1, 3]) | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
assert_col_equal(t['a'], [6, 3, 5, 2]) | |
# mode should only affect t | |
assert np.all(t2.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t2['a'][0] = 6 | |
assert np.all(t2.indices[0].sorted_data() == [1, 2, 3, 4, 0]) | |
# make sure non-modify mode is exited correctly | |
assert np.all(t.indices[0].sorted_data() == [3, 1, 2, 0]) | |
if isinstance(t['a'], BaseColumn): | |
assert len(t['a'][::-1].info.indices) == 0 | |
with t.index_mode('copy_on_getitem'): | |
> assert len(t['a'][[1, 2]].info.indices) == 1 | |
E AssertionError: assert 0 == 1 | |
E + where 0 = len([]) | |
E + where [] = name = a\ndtype = int64\nclass = Column\nn_bad = 0\nlength = 2\n.indices | |
E + where name = a\ndtype = int64\nclass = Column\nn_bad = 0\nlength = 2\n = <Column name='a' dtype='int64' length=2>\n3\n5.info | |
pypy/site-packages/astropy/table/tests/test_index.py:366: AssertionError | |
___________ TestIndex.test_index_modes[unmasked-main_col0-SCEngine] ____________ | |
self = <astropy.table.tests.test_index.TestIndex object at 0x0000000017a6b168> | |
main_col = [1, 2, 3, 4, 5] | |
table_types = <astropy.table.tests.conftest.table_types.<locals>.TableTypes object at 0x0000000017a884b8> | |
engine = <class 'astropy.table.soco.SCEngine'> | |
def test_index_modes(self, main_col, table_types, engine): | |
self._setup(main_col, table_types) | |
t = self.t | |
t.add_index('a', engine=engine) | |
# first, no special mode | |
assert len(t[[1, 3]].indices) == 1 | |
assert len(t[::-1].indices) == 1 | |
assert len(self._table_type(t).indices) == 1 | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t2 = t.copy() | |
# non-copy mode | |
with t.index_mode('discard_on_copy'): | |
assert len(t[[1, 3]].indices) == 0 | |
assert len(t[::-1].indices) == 0 | |
assert len(self._table_type(t).indices) == 0 | |
assert len(t2.copy().indices) == 1 # mode should only affect t | |
# make sure non-copy mode is exited correctly | |
assert len(t[[1, 3]].indices) == 1 | |
if not self.mutable: | |
return | |
# non-modify mode | |
with t.index_mode('freeze'): | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t['a'][0] = 6 | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t.add_row((2, 1.5, '12')) | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t.remove_rows([1, 3]) | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
assert_col_equal(t['a'], [6, 3, 5, 2]) | |
# mode should only affect t | |
assert np.all(t2.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t2['a'][0] = 6 | |
assert np.all(t2.indices[0].sorted_data() == [1, 2, 3, 4, 0]) | |
# make sure non-modify mode is exited correctly | |
assert np.all(t.indices[0].sorted_data() == [3, 1, 2, 0]) | |
if isinstance(t['a'], BaseColumn): | |
assert len(t['a'][::-1].info.indices) == 0 | |
with t.index_mode('copy_on_getitem'): | |
> assert len(t['a'][[1, 2]].info.indices) == 1 | |
E AssertionError: assert 0 == 1 | |
E + where 0 = len([]) | |
E + where [] = name = a\ndtype = int64\nclass = Column\nn_bad = 0\nlength = 2\n.indices | |
E + where name = a\ndtype = int64\nclass = Column\nn_bad = 0\nlength = 2\n = <Column name='a' dtype='int64' length=2>\n3\n5.info | |
pypy/site-packages/astropy/table/tests/test_index.py:366: AssertionError | |
______________ TestIndex.test_index_modes[subclass-main_col0-BST] ______________ | |
self = <astropy.table.tests.test_index.TestIndex object at 0x000000001ffadda8> | |
main_col = [1, 2, 3, 4, 5] | |
table_types = <astropy.table.tests.conftest.table_types.<locals>.TableTypes object at 0x000000001ffadb78> | |
engine = <class 'astropy.table.bst.BST'> | |
def test_index_modes(self, main_col, table_types, engine): | |
self._setup(main_col, table_types) | |
t = self.t | |
t.add_index('a', engine=engine) | |
# first, no special mode | |
assert len(t[[1, 3]].indices) == 1 | |
assert len(t[::-1].indices) == 1 | |
assert len(self._table_type(t).indices) == 1 | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t2 = t.copy() | |
# non-copy mode | |
with t.index_mode('discard_on_copy'): | |
assert len(t[[1, 3]].indices) == 0 | |
assert len(t[::-1].indices) == 0 | |
assert len(self._table_type(t).indices) == 0 | |
assert len(t2.copy().indices) == 1 # mode should only affect t | |
# make sure non-copy mode is exited correctly | |
assert len(t[[1, 3]].indices) == 1 | |
if not self.mutable: | |
return | |
# non-modify mode | |
with t.index_mode('freeze'): | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t['a'][0] = 6 | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t.add_row((2, 1.5, '12')) | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t.remove_rows([1, 3]) | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
assert_col_equal(t['a'], [6, 3, 5, 2]) | |
# mode should only affect t | |
assert np.all(t2.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t2['a'][0] = 6 | |
assert np.all(t2.indices[0].sorted_data() == [1, 2, 3, 4, 0]) | |
# make sure non-modify mode is exited correctly | |
assert np.all(t.indices[0].sorted_data() == [3, 1, 2, 0]) | |
if isinstance(t['a'], BaseColumn): | |
assert len(t['a'][::-1].info.indices) == 0 | |
with t.index_mode('copy_on_getitem'): | |
> assert len(t['a'][[1, 2]].info.indices) == 1 | |
E AssertionError: assert 0 == 1 | |
E + where 0 = len([]) | |
E + where [] = name = a\ndtype = int64\nclass = MyColumn\nn_bad = 0\nlength = 2\n.indices | |
E + where name = a\ndtype = int64\nclass = MyColumn\nn_bad = 0\nlength = 2\n = <MyColumn name='a' dtype='int64' length=2>\n3\n5.info | |
pypy/site-packages/astropy/table/tests/test_index.py:366: AssertionError | |
__________ TestIndex.test_index_modes[subclass-main_col0-SortedArray] __________ | |
self = <astropy.table.tests.test_index.TestIndex object at 0x00000000061302f8> | |
main_col = [1, 2, 3, 4, 5] | |
table_types = <astropy.table.tests.conftest.table_types.<locals>.TableTypes object at 0x000000000614d980> | |
engine = <class 'astropy.table.sorted_array.SortedArray'> | |
def test_index_modes(self, main_col, table_types, engine): | |
self._setup(main_col, table_types) | |
t = self.t | |
t.add_index('a', engine=engine) | |
# first, no special mode | |
assert len(t[[1, 3]].indices) == 1 | |
assert len(t[::-1].indices) == 1 | |
assert len(self._table_type(t).indices) == 1 | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t2 = t.copy() | |
# non-copy mode | |
with t.index_mode('discard_on_copy'): | |
assert len(t[[1, 3]].indices) == 0 | |
assert len(t[::-1].indices) == 0 | |
assert len(self._table_type(t).indices) == 0 | |
assert len(t2.copy().indices) == 1 # mode should only affect t | |
# make sure non-copy mode is exited correctly | |
assert len(t[[1, 3]].indices) == 1 | |
if not self.mutable: | |
return | |
# non-modify mode | |
with t.index_mode('freeze'): | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t['a'][0] = 6 | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t.add_row((2, 1.5, '12')) | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t.remove_rows([1, 3]) | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
assert_col_equal(t['a'], [6, 3, 5, 2]) | |
# mode should only affect t | |
assert np.all(t2.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t2['a'][0] = 6 | |
assert np.all(t2.indices[0].sorted_data() == [1, 2, 3, 4, 0]) | |
# make sure non-modify mode is exited correctly | |
assert np.all(t.indices[0].sorted_data() == [3, 1, 2, 0]) | |
if isinstance(t['a'], BaseColumn): | |
assert len(t['a'][::-1].info.indices) == 0 | |
with t.index_mode('copy_on_getitem'): | |
> assert len(t['a'][[1, 2]].info.indices) == 1 | |
E AssertionError: assert 0 == 1 | |
E + where 0 = len([]) | |
E + where [] = name = a\ndtype = int64\nclass = MyColumn\nn_bad = 0\nlength = 2\n.indices | |
E + where name = a\ndtype = int64\nclass = MyColumn\nn_bad = 0\nlength = 2\n = <MyColumn name='a' dtype='int64' length=2>\n3\n5.info | |
pypy/site-packages/astropy/table/tests/test_index.py:366: AssertionError | |
___________ TestIndex.test_index_modes[subclass-main_col0-SCEngine] ____________ | |
self = <astropy.table.tests.test_index.TestIndex object at 0x000000000d5a1520> | |
main_col = [1, 2, 3, 4, 5] | |
table_types = <astropy.table.tests.conftest.table_types.<locals>.TableTypes object at 0x000000000d5a1328> | |
engine = <class 'astropy.table.soco.SCEngine'> | |
def test_index_modes(self, main_col, table_types, engine): | |
self._setup(main_col, table_types) | |
t = self.t | |
t.add_index('a', engine=engine) | |
# first, no special mode | |
assert len(t[[1, 3]].indices) == 1 | |
assert len(t[::-1].indices) == 1 | |
assert len(self._table_type(t).indices) == 1 | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t2 = t.copy() | |
# non-copy mode | |
with t.index_mode('discard_on_copy'): | |
assert len(t[[1, 3]].indices) == 0 | |
assert len(t[::-1].indices) == 0 | |
assert len(self._table_type(t).indices) == 0 | |
assert len(t2.copy().indices) == 1 # mode should only affect t | |
# make sure non-copy mode is exited correctly | |
assert len(t[[1, 3]].indices) == 1 | |
if not self.mutable: | |
return | |
# non-modify mode | |
with t.index_mode('freeze'): | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t['a'][0] = 6 | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t.add_row((2, 1.5, '12')) | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t.remove_rows([1, 3]) | |
assert np.all(t.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
assert_col_equal(t['a'], [6, 3, 5, 2]) | |
# mode should only affect t | |
assert np.all(t2.indices[0].sorted_data() == [0, 1, 2, 3, 4]) | |
t2['a'][0] = 6 | |
assert np.all(t2.indices[0].sorted_data() == [1, 2, 3, 4, 0]) | |
# make sure non-modify mode is exited correctly | |
assert np.all(t.indices[0].sorted_data() == [3, 1, 2, 0]) | |
if isinstance(t['a'], BaseColumn): | |
assert len(t['a'][::-1].info.indices) == 0 | |
with t.index_mode('copy_on_getitem'): | |
> assert len(t['a'][[1, 2]].info.indices) == 1 | |
E AssertionError: assert 0 == 1 | |
E + where 0 = len([]) | |
E + where [] = name = a\ndtype = int64\nclass = MyColumn\nn_bad = 0\nlength = 2\n.indices | |
E + where name = a\ndtype = int64\nclass = MyColumn\nn_bad = 0\nlength = 2\n = <MyColumn name='a' dtype='int64' length=2>\n3\n5.info | |
pypy/site-packages/astropy/table/tests/test_index.py:366: AssertionError | |
____________________________ test_lost_parent_error ____________________________ | |
def test_lost_parent_error(): | |
c = table.Column([1, 2, 3], name='a') | |
with pytest.raises(AttributeError) as err: | |
> c[:].info.name | |
E Failed: DID NOT RAISE <class 'AttributeError'> | |
pypy/site-packages/astropy/table/tests/test_info.py:254: Failed | |
___________ TestConvertNumpyArray.test_byteswap_fits_array[unmasked] ___________ | |
self = <astropy.table.tests.test_table.TestConvertNumpyArray object at 0x000000001173a918> | |
table_types = <astropy.table.tests.conftest.table_types.<locals>.TableTypes object at 0x000000001173a800> | |
def test_byteswap_fits_array(self, table_types): | |
""" | |
Test for https://github.com/astropy/astropy/pull/4080, demonstrating | |
that FITS tables are converted to native byte order. | |
""" | |
non_native_order = ('>', '<')[sys.byteorder != 'little'] | |
filename = get_pkg_data_filename('data/tb.fits', | |
'astropy.io.fits.tests') | |
t = table_types.Table.read(filename) | |
arr = t.as_array() | |
for idx in range(len(arr.dtype)): | |
assert arr.dtype[idx].byteorder != non_native_order | |
with fits.open(filename, character_as_bytes=True) as hdul: | |
data = hdul[1].data | |
for colname in data.columns.names: | |
assert np.all(data[colname] == arr[colname]) | |
arr2 = t.as_array(keep_byteorder=True) | |
for colname in data.columns.names: | |
> assert (data[colname].dtype.byteorder == | |
arr2[colname].dtype.byteorder) | |
pypy/site-packages/astropy/table/tests/test_table.py:1326: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________ TestConvertNumpyArray.test_byteswap_fits_array[masked] ____________ | |
self = <astropy.table.tests.test_table.TestConvertNumpyArray object at 0x0000000019f8ed40> | |
table_types = <astropy.table.tests.conftest.table_types.<locals>.TableTypes object at 0x0000000019f8ec60> | |
def test_byteswap_fits_array(self, table_types): | |
""" | |
Test for https://github.com/astropy/astropy/pull/4080, demonstrating | |
that FITS tables are converted to native byte order. | |
""" | |
non_native_order = ('>', '<')[sys.byteorder != 'little'] | |
filename = get_pkg_data_filename('data/tb.fits', | |
'astropy.io.fits.tests') | |
t = table_types.Table.read(filename) | |
arr = t.as_array() | |
for idx in range(len(arr.dtype)): | |
assert arr.dtype[idx].byteorder != non_native_order | |
with fits.open(filename, character_as_bytes=True) as hdul: | |
data = hdul[1].data | |
for colname in data.columns.names: | |
assert np.all(data[colname] == arr[colname]) | |
arr2 = t.as_array(keep_byteorder=True) | |
for colname in data.columns.names: | |
> assert (data[colname].dtype.byteorder == | |
arr2[colname].dtype.byteorder) | |
pypy/site-packages/astropy/table/tests/test_table.py:1326: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
___________ TestConvertNumpyArray.test_byteswap_fits_array[subclass] ___________ | |
self = <astropy.table.tests.test_table.TestConvertNumpyArray object at 0x0000000021693750> | |
table_types = <astropy.table.tests.conftest.table_types.<locals>.TableTypes object at 0x0000000021693670> | |
def test_byteswap_fits_array(self, table_types): | |
""" | |
Test for https://github.com/astropy/astropy/pull/4080, demonstrating | |
that FITS tables are converted to native byte order. | |
""" | |
non_native_order = ('>', '<')[sys.byteorder != 'little'] | |
filename = get_pkg_data_filename('data/tb.fits', | |
'astropy.io.fits.tests') | |
t = table_types.Table.read(filename) | |
arr = t.as_array() | |
for idx in range(len(arr.dtype)): | |
assert arr.dtype[idx].byteorder != non_native_order | |
with fits.open(filename, character_as_bytes=True) as hdul: | |
data = hdul[1].data | |
for colname in data.columns.names: | |
assert np.all(data[colname] == arr[colname]) | |
arr2 = t.as_array(keep_byteorder=True) | |
for colname in data.columns.names: | |
> assert (data[colname].dtype.byteorder == | |
arr2[colname].dtype.byteorder) | |
pypy/site-packages/astropy/table/tests/test_table.py:1326: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:381: in __exit__ | |
self.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
____________ test_replace_update_column_via_setitem_warnings_slice _____________ | |
def test_replace_update_column_via_setitem_warnings_slice(): | |
""" | |
Test warnings related to table replace change in #5556: | |
Replace a slice, one warning. | |
""" | |
t = table.Table([[1, 2, 3], [4, 5, 6]], names=['a', 'b']) | |
with catch_warnings() as w: | |
with table.conf.set_temp('replace_warnings', | |
['refcount', 'attributes', 'slice']): | |
t2 = t[:2] | |
t2['a'] = 0 # in-place slice update | |
assert np.all(t['a'] == [0, 0, 3]) | |
assert len(w) == 0 | |
t2['a'] = [10, 20] # replace slice | |
> assert len(w) == 1 | |
E assert 0 == 1 | |
E + where 0 = len([]) | |
pypy/site-packages/astropy/table/tests/test_table.py:2234: AssertionError | |
__________ test_replace_update_column_via_setitem_warnings_attributes __________ | |
def test_replace_update_column_via_setitem_warnings_attributes(): | |
""" | |
Test warnings related to table replace change in #5556: | |
Lost attributes. | |
""" | |
t = table.Table([[1, 2, 3], [4, 5, 6]], names=['a', 'b']) | |
t['a'].unit = 'm' | |
with catch_warnings() as w: | |
with table.conf.set_temp('replace_warnings', | |
['refcount', 'attributes', 'slice']): | |
t['a'] = [10, 20, 30] | |
> assert len(w) == 1 | |
E assert 0 == 1 | |
E + where 0 = len([]) | |
pypy/site-packages/astropy/table/tests/test_table.py:2250: AssertionError | |
___________ test_replace_update_column_via_setitem_warnings_refcount ___________ | |
def test_replace_update_column_via_setitem_warnings_refcount(): | |
""" | |
Test warnings related to table replace change in #5556: | |
Reference count changes. | |
""" | |
t = table.Table([[1, 2, 3], [4, 5, 6]], names=['a', 'b']) | |
ta = t['a'] # Generate an extra reference to original column | |
with catch_warnings() as w: | |
with table.conf.set_temp('replace_warnings', | |
['refcount', 'attributes', 'slice']): | |
t['a'] = [10, 20, 30] | |
> assert len(w) == 1 | |
E assert 0 == 1 | |
E + where 0 = len([]) | |
pypy/site-packages/astropy/table/tests/test_table.py:2266: AssertionError | |
________________________ TestTimeDelta.test_set_format _________________________ | |
self = <astropy.time.tests.test_delta.TestTimeDelta object at 0x0000000008f6c2f8> | |
def test_set_format(self): | |
""" | |
Test basics of setting format attribute. | |
""" | |
dt = TimeDelta(86400.0, format='sec') | |
assert dt.value == 86400.0 | |
assert dt.format == 'sec' | |
dt.format = 'jd' | |
assert dt.value == 1.0 | |
assert dt.format == 'jd' | |
dt.format = 'datetime' | |
> assert dt.value == timedelta(days=1) | |
pypy/site-packages/astropy/time/tests/test_delta.py:267: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/time/core.py:1009: in value | |
return self.to_value(self.format, None) | |
pypy/site-packages/astropy/time/core.py:2402: in to_value | |
return super().to_value(*args, **kwargs) | |
pypy/site-packages/astropy/time/core.py:994: in to_value | |
parent=tm, **kwargs)) | |
pypy/site-packages/astropy/time/formats.py:303: in to_value | |
return self.mask_if_needed(self.value) | |
pypy/site-packages/astropy/time/formats.py:1563: in value | |
microseconds=jd2_*86400*1e6) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
cls = <class 'datetime.timedelta'>, days = 0.0, seconds = 0.0 | |
microseconds = 0.0, milliseconds = 0, minutes = 0, hours = 0, weeks = 0 | |
def __new__(cls, days=0, seconds=0, microseconds=0, | |
milliseconds=0, minutes=0, hours=0, weeks=0): | |
# Doing this efficiently and accurately in C is going to be difficult | |
# and error-prone, due to ubiquitous overflow possibilities, and that | |
# C double doesn't have enough bits of precision to represent | |
# microseconds over 10K years faithfully. The code here tries to make | |
# explicit where go-fast assumptions can be relied on, in order to | |
# guide the C implementation; it's way more convoluted than speed- | |
# ignoring auto-overflow-to-long idiomatic Python could be. | |
# XXX Check that all inputs are ints or floats. | |
# Final values, all integer. | |
# s and us fit in 32-bit signed ints; d isn't bounded. | |
d = s = us = 0 | |
# Normalize everything to days, seconds, microseconds. | |
days += weeks*7 | |
seconds += minutes*60 + hours*3600 | |
microseconds += milliseconds*1000 | |
# Get rid of all fractions, and normalize s and us. | |
# Take a deep breath <wink>. | |
if isinstance(days, float): | |
dayfrac, days = _math.modf(days) | |
daysecondsfrac, daysecondswhole = _math.modf(dayfrac * (24.*3600.)) | |
assert daysecondswhole == int(daysecondswhole) # can't overflow | |
s = int(daysecondswhole) | |
assert days == int(days) | |
d = int(days) | |
else: | |
daysecondsfrac = 0.0 | |
d = days | |
assert isinstance(daysecondsfrac, float) | |
assert abs(daysecondsfrac) <= 1.0 | |
assert isinstance(d, int) | |
assert abs(s) <= 24 * 3600 | |
# days isn't referenced again before redefinition | |
if isinstance(seconds, float): | |
secondsfrac, seconds = _math.modf(seconds) | |
assert seconds == int(seconds) | |
seconds = int(seconds) | |
secondsfrac += daysecondsfrac | |
assert abs(secondsfrac) <= 2.0 | |
else: | |
secondsfrac = daysecondsfrac | |
# daysecondsfrac isn't referenced again | |
assert isinstance(secondsfrac, float) | |
assert abs(secondsfrac) <= 2.0 | |
assert isinstance(seconds, int) | |
days, seconds = divmod(seconds, 24*3600) | |
d += days | |
s += int(seconds) # can't overflow | |
assert isinstance(s, int) | |
assert abs(s) <= 2 * 24 * 3600 | |
# seconds isn't referenced again before redefinition | |
usdouble = secondsfrac * 1e6 | |
assert abs(usdouble) < 2.1e6 # exact value not critical | |
# secondsfrac isn't referenced again | |
if isinstance(microseconds, float): | |
microseconds = round(microseconds + usdouble) | |
seconds, microseconds = divmod(microseconds, 1000000) | |
days, seconds = divmod(seconds, 24*3600) | |
d += days | |
s += seconds | |
else: | |
microseconds = int(microseconds) | |
seconds, microseconds = divmod(microseconds, 1000000) | |
days, seconds = divmod(seconds, 24*3600) | |
d += days | |
s += seconds | |
microseconds = round(microseconds + usdouble) | |
> assert isinstance(s, int) | |
E AssertionError | |
Downloads/pypy3.6-7.2.0-linux_x86_64-portable/lib-python/3/datetime.py:434: AssertionError | |
_________________________ test_python_timedelta_scalar _________________________ | |
def test_python_timedelta_scalar(): | |
td = timedelta(days=1, seconds=1) | |
td1 = TimeDelta(td, format='datetime') | |
assert td1.sec == 86401.0 | |
td2 = TimeDelta(86401.0, format='sec') | |
> assert td2.datetime == td | |
pypy/site-packages/astropy/time/tests/test_delta.py:575: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/time/core.py:1687: in __getattr__ | |
return self.to_value(attr, subfmt=None) | |
pypy/site-packages/astropy/time/core.py:2402: in to_value | |
return super().to_value(*args, **kwargs) | |
pypy/site-packages/astropy/time/core.py:994: in to_value | |
parent=tm, **kwargs)) | |
pypy/site-packages/astropy/time/formats.py:303: in to_value | |
return self.mask_if_needed(self.value) | |
pypy/site-packages/astropy/time/formats.py:1563: in value | |
microseconds=jd2_*86400*1e6) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
cls = <class 'datetime.timedelta'>, days = 0.0, seconds = 1.0 | |
microseconds = 0.0, milliseconds = 0, minutes = 0, hours = 0, weeks = 0 | |
def __new__(cls, days=0, seconds=0, microseconds=0, | |
milliseconds=0, minutes=0, hours=0, weeks=0): | |
# Doing this efficiently and accurately in C is going to be difficult | |
# and error-prone, due to ubiquitous overflow possibilities, and that | |
# C double doesn't have enough bits of precision to represent | |
# microseconds over 10K years faithfully. The code here tries to make | |
# explicit where go-fast assumptions can be relied on, in order to | |
# guide the C implementation; it's way more convoluted than speed- | |
# ignoring auto-overflow-to-long idiomatic Python could be. | |
# XXX Check that all inputs are ints or floats. | |
# Final values, all integer. | |
# s and us fit in 32-bit signed ints; d isn't bounded. | |
d = s = us = 0 | |
# Normalize everything to days, seconds, microseconds. | |
days += weeks*7 | |
seconds += minutes*60 + hours*3600 | |
microseconds += milliseconds*1000 | |
# Get rid of all fractions, and normalize s and us. | |
# Take a deep breath <wink>. | |
if isinstance(days, float): | |
dayfrac, days = _math.modf(days) | |
daysecondsfrac, daysecondswhole = _math.modf(dayfrac * (24.*3600.)) | |
assert daysecondswhole == int(daysecondswhole) # can't overflow | |
s = int(daysecondswhole) | |
assert days == int(days) | |
d = int(days) | |
else: | |
daysecondsfrac = 0.0 | |
d = days | |
assert isinstance(daysecondsfrac, float) | |
assert abs(daysecondsfrac) <= 1.0 | |
assert isinstance(d, int) | |
assert abs(s) <= 24 * 3600 | |
# days isn't referenced again before redefinition | |
if isinstance(seconds, float): | |
secondsfrac, seconds = _math.modf(seconds) | |
assert seconds == int(seconds) | |
seconds = int(seconds) | |
secondsfrac += daysecondsfrac | |
assert abs(secondsfrac) <= 2.0 | |
else: | |
secondsfrac = daysecondsfrac | |
# daysecondsfrac isn't referenced again | |
assert isinstance(secondsfrac, float) | |
assert abs(secondsfrac) <= 2.0 | |
assert isinstance(seconds, int) | |
days, seconds = divmod(seconds, 24*3600) | |
d += days | |
s += int(seconds) # can't overflow | |
assert isinstance(s, int) | |
assert abs(s) <= 2 * 24 * 3600 | |
# seconds isn't referenced again before redefinition | |
usdouble = secondsfrac * 1e6 | |
assert abs(usdouble) < 2.1e6 # exact value not critical | |
# secondsfrac isn't referenced again | |
if isinstance(microseconds, float): | |
microseconds = round(microseconds + usdouble) | |
seconds, microseconds = divmod(microseconds, 1000000) | |
days, seconds = divmod(seconds, 24*3600) | |
d += days | |
s += seconds | |
else: | |
microseconds = int(microseconds) | |
seconds, microseconds = divmod(microseconds, 1000000) | |
days, seconds = divmod(seconds, 24*3600) | |
d += days | |
s += seconds | |
microseconds = round(microseconds + usdouble) | |
> assert isinstance(s, int) | |
E AssertionError | |
Downloads/pypy3.6-7.2.0-linux_x86_64-portable/lib-python/3/datetime.py:434: AssertionError | |
_________________________ test_python_timedelta_vector _________________________ | |
def test_python_timedelta_vector(): | |
td = [[timedelta(days=1), timedelta(days=2)], | |
[timedelta(days=3), timedelta(days=4)]] | |
td1 = TimeDelta(td, format='datetime') | |
assert np.all(td1.jd == [[1, 2], [3, 4]]) | |
td2 = TimeDelta([[1, 2], [3, 4]], format='jd') | |
> assert np.all(td2.datetime == td) | |
pypy/site-packages/astropy/time/tests/test_delta.py:587: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/time/core.py:1687: in __getattr__ | |
return self.to_value(attr, subfmt=None) | |
pypy/site-packages/astropy/time/core.py:2402: in to_value | |
return super().to_value(*args, **kwargs) | |
pypy/site-packages/astropy/time/core.py:994: in to_value | |
parent=tm, **kwargs)) | |
pypy/site-packages/astropy/time/formats.py:303: in to_value | |
return self.mask_if_needed(self.value) | |
pypy/site-packages/astropy/time/formats.py:1563: in value | |
microseconds=jd2_*86400*1e6) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
cls = <class 'datetime.timedelta'>, days = 0.0, seconds = 0.0 | |
microseconds = 0.0, milliseconds = 0, minutes = 0, hours = 0, weeks = 0 | |
def __new__(cls, days=0, seconds=0, microseconds=0, | |
milliseconds=0, minutes=0, hours=0, weeks=0): | |
# Doing this efficiently and accurately in C is going to be difficult | |
# and error-prone, due to ubiquitous overflow possibilities, and that | |
# C double doesn't have enough bits of precision to represent | |
# microseconds over 10K years faithfully. The code here tries to make | |
# explicit where go-fast assumptions can be relied on, in order to | |
# guide the C implementation; it's way more convoluted than speed- | |
# ignoring auto-overflow-to-long idiomatic Python could be. | |
# XXX Check that all inputs are ints or floats. | |
# Final values, all integer. | |
# s and us fit in 32-bit signed ints; d isn't bounded. | |
d = s = us = 0 | |
# Normalize everything to days, seconds, microseconds. | |
days += weeks*7 | |
seconds += minutes*60 + hours*3600 | |
microseconds += milliseconds*1000 | |
# Get rid of all fractions, and normalize s and us. | |
# Take a deep breath <wink>. | |
if isinstance(days, float): | |
dayfrac, days = _math.modf(days) | |
daysecondsfrac, daysecondswhole = _math.modf(dayfrac * (24.*3600.)) | |
assert daysecondswhole == int(daysecondswhole) # can't overflow | |
s = int(daysecondswhole) | |
assert days == int(days) | |
d = int(days) | |
else: | |
daysecondsfrac = 0.0 | |
d = days | |
assert isinstance(daysecondsfrac, float) | |
assert abs(daysecondsfrac) <= 1.0 | |
assert isinstance(d, int) | |
assert abs(s) <= 24 * 3600 | |
# days isn't referenced again before redefinition | |
if isinstance(seconds, float): | |
secondsfrac, seconds = _math.modf(seconds) | |
assert seconds == int(seconds) | |
seconds = int(seconds) | |
secondsfrac += daysecondsfrac | |
assert abs(secondsfrac) <= 2.0 | |
else: | |
secondsfrac = daysecondsfrac | |
# daysecondsfrac isn't referenced again | |
assert isinstance(secondsfrac, float) | |
assert abs(secondsfrac) <= 2.0 | |
assert isinstance(seconds, int) | |
days, seconds = divmod(seconds, 24*3600) | |
d += days | |
s += int(seconds) # can't overflow | |
assert isinstance(s, int) | |
assert abs(s) <= 2 * 24 * 3600 | |
# seconds isn't referenced again before redefinition | |
usdouble = secondsfrac * 1e6 | |
assert abs(usdouble) < 2.1e6 # exact value not critical | |
# secondsfrac isn't referenced again | |
if isinstance(microseconds, float): | |
microseconds = round(microseconds + usdouble) | |
seconds, microseconds = divmod(microseconds, 1000000) | |
days, seconds = divmod(seconds, 24*3600) | |
d += days | |
s += seconds | |
else: | |
microseconds = int(microseconds) | |
seconds, microseconds = divmod(microseconds, 1000000) | |
days, seconds = divmod(seconds, 24*3600) | |
d += days | |
s += seconds | |
microseconds = round(microseconds + usdouble) | |
> assert isinstance(s, int) | |
E AssertionError | |
Downloads/pypy3.6-7.2.0-linux_x86_64-portable/lib-python/3/datetime.py:434: AssertionError | |
__________________________ test_timedelta_to_datetime __________________________ | |
def test_timedelta_to_datetime(): | |
td = TimeDelta(1, format='jd') | |
> assert td.to_datetime() == timedelta(days=1) | |
pypy/site-packages/astropy/time/tests/test_delta.py:593: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/time/core.py:2124: in to_datetime | |
return tm._shaped_like_input(tm._time.value) | |
pypy/site-packages/astropy/time/formats.py:1563: in value | |
microseconds=jd2_*86400*1e6) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
cls = <class 'datetime.timedelta'>, days = 0.0, seconds = 0.0 | |
microseconds = 0.0, milliseconds = 0, minutes = 0, hours = 0, weeks = 0 | |
def __new__(cls, days=0, seconds=0, microseconds=0, | |
milliseconds=0, minutes=0, hours=0, weeks=0): | |
# Doing this efficiently and accurately in C is going to be difficult | |
# and error-prone, due to ubiquitous overflow possibilities, and that | |
# C double doesn't have enough bits of precision to represent | |
# microseconds over 10K years faithfully. The code here tries to make | |
# explicit where go-fast assumptions can be relied on, in order to | |
# guide the C implementation; it's way more convoluted than speed- | |
# ignoring auto-overflow-to-long idiomatic Python could be. | |
# XXX Check that all inputs are ints or floats. | |
# Final values, all integer. | |
# s and us fit in 32-bit signed ints; d isn't bounded. | |
d = s = us = 0 | |
# Normalize everything to days, seconds, microseconds. | |
days += weeks*7 | |
seconds += minutes*60 + hours*3600 | |
microseconds += milliseconds*1000 | |
# Get rid of all fractions, and normalize s and us. | |
# Take a deep breath <wink>. | |
if isinstance(days, float): | |
dayfrac, days = _math.modf(days) | |
daysecondsfrac, daysecondswhole = _math.modf(dayfrac * (24.*3600.)) | |
assert daysecondswhole == int(daysecondswhole) # can't overflow | |
s = int(daysecondswhole) | |
assert days == int(days) | |
d = int(days) | |
else: | |
daysecondsfrac = 0.0 | |
d = days | |
assert isinstance(daysecondsfrac, float) | |
assert abs(daysecondsfrac) <= 1.0 | |
assert isinstance(d, int) | |
assert abs(s) <= 24 * 3600 | |
# days isn't referenced again before redefinition | |
if isinstance(seconds, float): | |
secondsfrac, seconds = _math.modf(seconds) | |
assert seconds == int(seconds) | |
seconds = int(seconds) | |
secondsfrac += daysecondsfrac | |
assert abs(secondsfrac) <= 2.0 | |
else: | |
secondsfrac = daysecondsfrac | |
# daysecondsfrac isn't referenced again | |
assert isinstance(secondsfrac, float) | |
assert abs(secondsfrac) <= 2.0 | |
assert isinstance(seconds, int) | |
days, seconds = divmod(seconds, 24*3600) | |
d += days | |
s += int(seconds) # can't overflow | |
assert isinstance(s, int) | |
assert abs(s) <= 2 * 24 * 3600 | |
# seconds isn't referenced again before redefinition | |
usdouble = secondsfrac * 1e6 | |
assert abs(usdouble) < 2.1e6 # exact value not critical | |
# secondsfrac isn't referenced again | |
if isinstance(microseconds, float): | |
microseconds = round(microseconds + usdouble) | |
seconds, microseconds = divmod(microseconds, 1000000) | |
days, seconds = divmod(seconds, 24*3600) | |
d += days | |
s += seconds | |
else: | |
microseconds = int(microseconds) | |
seconds, microseconds = divmod(microseconds, 1000000) | |
days, seconds = divmod(seconds, 24*3600) | |
d += days | |
s += seconds | |
microseconds = round(microseconds + usdouble) | |
> assert isinstance(s, int) | |
E AssertionError | |
Downloads/pypy3.6-7.2.0-linux_x86_64-portable/lib-python/3/datetime.py:434: AssertionError | |
__________________________________ test_slice __________________________________ | |
def test_slice(): | |
mywcs = WCS(naxis=2) | |
mywcs.wcs.crval = [1, 1] | |
mywcs.wcs.cdelt = [0.1, 0.1] | |
mywcs.wcs.crpix = [1, 1] | |
mywcs._naxis = [1000, 500] | |
pscale = 0.1 # from cdelt | |
slice_wcs = mywcs.slice([slice(1, None), slice(0, None)]) | |
assert np.all(slice_wcs.wcs.crpix == np.array([1, 0])) | |
assert slice_wcs._naxis == [1000, 499] | |
# test that CRPIX maps to CRVAL: | |
assert_allclose( | |
slice_wcs.wcs_pix2world(*slice_wcs.wcs.crpix, 1), | |
slice_wcs.wcs.crval, rtol=0.0, atol=1e-6 * pscale | |
) | |
slice_wcs = mywcs.slice([slice(1, None, 2), slice(0, None, 4)]) | |
assert np.all(slice_wcs.wcs.crpix == np.array([0.625, 0.25])) | |
assert np.all(slice_wcs.wcs.cdelt == np.array([0.4, 0.2])) | |
assert slice_wcs._naxis == [250, 250] | |
slice_wcs = mywcs.slice([slice(None, None, 2), slice(0, None, 2)]) | |
assert np.all(slice_wcs.wcs.cdelt == np.array([0.2, 0.2])) | |
assert slice_wcs._naxis == [500, 250] | |
# Non-integral values do not alter the naxis attribute | |
with pytest.warns(AstropyUserWarning): | |
> slice_wcs = mywcs.slice([slice(50.), slice(20.)]) | |
pypy/site-packages/astropy/wcs/tests/test_utils.py:139: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = WCS Keywords | |
Number of WCS axes: 2 | |
CTYPE : '' '' | |
CRVAL : 1.0 1.0 | |
CRPIX : 1.0 1.0 | |
PC1_1 PC1_2 : 1.0 0.0 | |
PC2_1 PC2_2 : 0.0 1.0 | |
CDELT : 0.1 0.1 | |
NAXIS : 1000 500 | |
view = [slice(None, 50.0, None), slice(None, 20.0, None)], numpy_order = True | |
def slice(self, view, numpy_order=True): | |
""" | |
Slice a WCS instance using a Numpy slice. The order of the slice should | |
be reversed (as for the data) compared to the natural WCS order. | |
Parameters | |
---------- | |
view : tuple | |
A tuple containing the same number of slices as the WCS system. | |
The ``step`` method, the third argument to a slice, is not | |
presently supported. | |
numpy_order : bool | |
Use numpy order, i.e. slice the WCS so that an identical slice | |
applied to a numpy array will slice the array and WCS in the same | |
way. If set to `False`, the WCS will be sliced in FITS order, | |
meaning the first slice will be applied to the *last* numpy index | |
but the *first* WCS axis. | |
Returns | |
------- | |
wcs_new : `~astropy.wcs.WCS` | |
A new resampled WCS axis | |
""" | |
if hasattr(view, '__len__') and len(view) > self.wcs.naxis: | |
raise ValueError("Must have # of slices <= # of WCS axes") | |
elif not hasattr(view, '__len__'): # view MUST be an iterable | |
view = [view] | |
if not all(isinstance(x, slice) for x in view): | |
# We need to drop some dimensions, but this may not always be | |
# possible with .sub due to correlated axes, so instead we use the | |
# generalized slicing infrastructure from astropy.wcs.wcsapi. | |
return SlicedFITSWCS(self, view) | |
# NOTE: we could in principle use SlicedFITSWCS as above for all slicing, | |
# but in the simple case where there are no axes dropped, we can just | |
# create a full WCS object with updated WCS parameters which is faster | |
# for this specific case and also backward-compatible. | |
wcs_new = self.deepcopy() | |
if wcs_new.sip is not None: | |
sip_crpix = wcs_new.sip.crpix.tolist() | |
for i, iview in enumerate(view): | |
if iview.step is not None and iview.step < 0: | |
raise NotImplementedError("Reversing an axis is not " | |
"implemented.") | |
if numpy_order: | |
wcs_index = self.wcs.naxis - 1 - i | |
else: | |
wcs_index = i | |
if iview.step is not None and iview.start is None: | |
# Slice from "None" is equivalent to slice from 0 (but one | |
# might want to downsample, so allow slices with | |
# None,None,step or None,stop,step) | |
iview = slice(0, iview.stop, iview.step) | |
if iview.start is not None: | |
if iview.step not in (None, 1): | |
crpix = self.wcs.crpix[wcs_index] | |
cdelt = self.wcs.cdelt[wcs_index] | |
# equivalently (keep this comment so you can compare eqns): | |
# wcs_new.wcs.crpix[wcs_index] = | |
# (crpix - iview.start)*iview.step + 0.5 - iview.step/2. | |
crp = ((crpix - iview.start - 1.)/iview.step | |
+ 0.5 + 1./iview.step/2.) | |
wcs_new.wcs.crpix[wcs_index] = crp | |
if wcs_new.sip is not None: | |
sip_crpix[wcs_index] = crp | |
wcs_new.wcs.cdelt[wcs_index] = cdelt * iview.step | |
else: | |
wcs_new.wcs.crpix[wcs_index] -= iview.start | |
if wcs_new.sip is not None: | |
sip_crpix[wcs_index] -= iview.start | |
try: | |
# range requires integers but the other attributes can also | |
# handle arbitrary values, so this needs to be in a try/except. | |
> nitems = len(builtins.range(self._naxis[wcs_index])[iview]) | |
E TypeError: 'float' object cannot be interpreted as an integer | |
pypy/site-packages/astropy/wcs/wcs.py:2997: TypeError | |
__________________________ test_validate_with_2_wcses __________________________ | |
def test_validate_with_2_wcses(): | |
# From Issue #2053 | |
with pytest.warns(AstropyUserWarning): | |
> results = wcs.validate(get_pkg_data_filename("data/2wcses.hdr")) | |
pypy/site-packages/astropy/wcs/tests/test_wcs.py:423: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
source = '/home/tom/pypy/site-packages/astropy/wcs/tests/data/2wcses.hdr' | |
def validate(source): | |
""" | |
Prints a WCS validation report for the given FITS file. | |
Parameters | |
---------- | |
source : str path, readable file-like object or `astropy.io.fits.HDUList` object | |
The FITS file to validate. | |
Returns | |
------- | |
results : WcsValidateResults instance | |
The result is returned as nested lists. The first level | |
corresponds to the HDUs in the given file. The next level has | |
an entry for each WCS found in that header. The special | |
subclass of list will pretty-print the results as a table when | |
printed. | |
""" | |
class _WcsValidateWcsResult(list): | |
def __init__(self, key): | |
self._key = key | |
def __repr__(self): | |
result = [" WCS key '{}':".format(self._key or ' ')] | |
if len(self): | |
for entry in self: | |
for i, line in enumerate(entry.splitlines()): | |
if i == 0: | |
initial_indent = ' - ' | |
else: | |
initial_indent = ' ' | |
result.extend( | |
textwrap.wrap( | |
line, | |
initial_indent=initial_indent, | |
subsequent_indent=' ')) | |
else: | |
result.append(" No issues.") | |
return '\n'.join(result) | |
class _WcsValidateHduResult(list): | |
def __init__(self, hdu_index, hdu_name): | |
self._hdu_index = hdu_index | |
self._hdu_name = hdu_name | |
list.__init__(self) | |
def __repr__(self): | |
if len(self): | |
if self._hdu_name: | |
hdu_name = f' ({self._hdu_name})' | |
else: | |
hdu_name = '' | |
result = [f'HDU {self._hdu_index}{hdu_name}:'] | |
for wcs in self: | |
result.append(repr(wcs)) | |
return '\n'.join(result) | |
return '' | |
class _WcsValidateResults(list): | |
def __repr__(self): | |
result = [] | |
for hdu in self: | |
content = repr(hdu) | |
if len(content): | |
result.append(content) | |
return '\n\n'.join(result) | |
global __warningregistry__ | |
if isinstance(source, fits.HDUList): | |
hdulist = source | |
else: | |
hdulist = fits.open(source) | |
results = _WcsValidateResults() | |
for i, hdu in enumerate(hdulist): | |
hdu_results = _WcsValidateHduResult(i, hdu.name) | |
results.append(hdu_results) | |
with warnings.catch_warnings(record=True) as warning_lines: | |
wcses = find_all_wcs( | |
hdu.header, relax=_wcs.WCSHDR_reject, | |
fix=False, _do_set=False) | |
for wcs in wcses: | |
wcs_results = _WcsValidateWcsResult(wcs.wcs.alt) | |
hdu_results.append(wcs_results) | |
try: | |
> del __warningregistry__ | |
E KeyError: '__warningregistry__' | |
pypy/site-packages/astropy/wcs/wcs.py:3311: KeyError | |
___________________________ test_validate_faulty_wcs ___________________________ | |
@pytest.mark.filterwarnings('ignore') | |
def test_validate_faulty_wcs(): | |
""" | |
From github issue #2053 | |
""" | |
h = fits.Header() | |
# Illegal WCS: | |
h['RADESYSA'] = 'ICRS' | |
h['PV2_1'] = 1.0 | |
hdu = fits.PrimaryHDU([[0]], header=h) | |
hdulist = fits.HDUList([hdu]) | |
# Check that this doesn't raise a NameError exception | |
> wcs.validate(hdulist) | |
pypy/site-packages/astropy/wcs/tests/test_wcs.py:663: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
source = [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x000000000ee29e88>] | |
def validate(source): | |
""" | |
Prints a WCS validation report for the given FITS file. | |
Parameters | |
---------- | |
source : str path, readable file-like object or `astropy.io.fits.HDUList` object | |
The FITS file to validate. | |
Returns | |
------- | |
results : WcsValidateResults instance | |
The result is returned as nested lists. The first level | |
corresponds to the HDUs in the given file. The next level has | |
an entry for each WCS found in that header. The special | |
subclass of list will pretty-print the results as a table when | |
printed. | |
""" | |
class _WcsValidateWcsResult(list): | |
def __init__(self, key): | |
self._key = key | |
def __repr__(self): | |
result = [" WCS key '{}':".format(self._key or ' ')] | |
if len(self): | |
for entry in self: | |
for i, line in enumerate(entry.splitlines()): | |
if i == 0: | |
initial_indent = ' - ' | |
else: | |
initial_indent = ' ' | |
result.extend( | |
textwrap.wrap( | |
line, | |
initial_indent=initial_indent, | |
subsequent_indent=' ')) | |
else: | |
result.append(" No issues.") | |
return '\n'.join(result) | |
class _WcsValidateHduResult(list): | |
def __init__(self, hdu_index, hdu_name): | |
self._hdu_index = hdu_index | |
self._hdu_name = hdu_name | |
list.__init__(self) | |
def __repr__(self): | |
if len(self): | |
if self._hdu_name: | |
hdu_name = f' ({self._hdu_name})' | |
else: | |
hdu_name = '' | |
result = [f'HDU {self._hdu_index}{hdu_name}:'] | |
for wcs in self: | |
result.append(repr(wcs)) | |
return '\n'.join(result) | |
return '' | |
class _WcsValidateResults(list): | |
def __repr__(self): | |
result = [] | |
for hdu in self: | |
content = repr(hdu) | |
if len(content): | |
result.append(content) | |
return '\n\n'.join(result) | |
global __warningregistry__ | |
if isinstance(source, fits.HDUList): | |
hdulist = source | |
else: | |
hdulist = fits.open(source) | |
results = _WcsValidateResults() | |
for i, hdu in enumerate(hdulist): | |
hdu_results = _WcsValidateHduResult(i, hdu.name) | |
results.append(hdu_results) | |
with warnings.catch_warnings(record=True) as warning_lines: | |
wcses = find_all_wcs( | |
hdu.header, relax=_wcs.WCSHDR_reject, | |
fix=False, _do_set=False) | |
for wcs in wcses: | |
wcs_results = _WcsValidateWcsResult(wcs.wcs.alt) | |
hdu_results.append(wcs_results) | |
try: | |
> del __warningregistry__ | |
E KeyError: '__warningregistry__' | |
pypy/site-packages/astropy/wcs/wcs.py:3311: KeyError | |
________________________________ test_to_fits_1 ________________________________ | |
def test_to_fits_1(): | |
""" | |
Test to_fits() with LookupTable distortion. | |
""" | |
fits_name = get_pkg_data_filename('data/dist.fits') | |
with pytest.warns(AstropyDeprecationWarning): | |
> w = wcs.WCS(fits_name) | |
pypy/site-packages/astropy/wcs/tests/test_wcs.py:1126: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
pypy/site-packages/astropy/wcs/wcs.py:510: in __init__ | |
fd.close() | |
pypy/site-packages/astropy/io/fits/hdu/hdulist.py:966: in close | |
self._file.close() | |
pypy/site-packages/astropy/io/fits/file.py:413: in close | |
self._maybe_close_mmap() | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = <astropy.io.fits.file._File <_io.FileIO [closed]>>, refcount_delta = 0 | |
def _maybe_close_mmap(self, refcount_delta=0): | |
""" | |
When mmap is in use these objects hold a reference to the mmap of the | |
file (so there is only one, shared by all HDUs that reference this | |
file). | |
This will close the mmap if there are no arrays referencing it. | |
""" | |
if (self._mmap is not None and | |
> sys.getrefcount(self._mmap) == 2 + refcount_delta): | |
E AttributeError: module 'sys' has no attribute 'getrefcount' | |
pypy/site-packages/astropy/io/fits/file.py:431: AttributeError | |
_________________________________ test_compare _________________________________ | |
def test_compare(): | |
header = get_pkg_data_contents('data/3d_cd.hdr', encoding='binary') | |
w = _wcs.Wcsprm(header) | |
w2 = _wcs.Wcsprm(header) | |
assert w == w2 | |
w.equinox = 42 | |
assert w == w2 | |
assert not w.compare(w2) | |
assert w.compare(w2, _wcs.WCSCOMPARE_ANCILLARY) | |
w = _wcs.Wcsprm(header) | |
w2 = _wcs.Wcsprm(header) | |
with pytest.warns(RuntimeWarning): | |
w.cdelt[0] = np.float32(0.00416666666666666666666666) | |
w2.cdelt[0] = np.float64(0.00416666666666666666666666) | |
assert not w.compare(w2) | |
> assert w.compare(w2, tolerance=1e-6) | |
E Failed: DID NOT WARN. No warnings of type (<class 'RuntimeWarning'>,) was emitted. The list of emitted warnings is: [UserWarning('cdelt will be ignored since cd is present',), UserWarning('cdelt will be ignored since cd is present',)]. | |
pypy/site-packages/astropy/wcs/tests/test_wcsprm.py:921: Failed | |
=============================== warnings summary =============================== | |
pypy/site-packages/astropy/io/ascii/tests/test_read.py::test_read_chunks_formats[False] | |
/home/tom/pypy/site-packages/astropy/table/table.py:1188: ResourceWarning: unclosed file <_io.BufferedReader name='data/ipac.dat.bz2'> | |
for col in cols: | |
pypy/site-packages/astropy/io/ascii/tests/test_read.py::test_read_chunks_formats[False] | |
/home/tom/pypy/site-packages/astropy/table/table.py:1188: ResourceWarning: unclosed file <_io.TextIOWrapper name='data/test5.dat' mode='r' encoding='UTF-8'> | |
for col in cols: | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py::TestChecksumFunctions::test_scaled_data | |
/home/tom/pypy/site-packages/astropy/io/fits/hdu/hdulist.py:1186: VerifyWarning: Error validating header for HDU #1 (note: Astropy uses zero-based indexing). | |
I/O operation on closed file | |
There may be extra bytes after the last HDU or the file is corrupted. | |
len(self), indent(str(exc))), VerifyWarning) | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py::TestChecksumFunctions::test_uint16_data | |
/home/tom/pypy/site-packages/astropy/io/fits/hdu/hdulist.py:1186: VerifyWarning: Error validating header for HDU #7 (note: Astropy uses zero-based indexing). | |
I/O operation on closed file | |
There may be extra bytes after the last HDU or the file is corrupted. | |
len(self), indent(str(exc))), VerifyWarning) | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py::TestChecksumFunctions::test_compressed_image_data | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py::TestChecksumFunctions::test_compressed_image_data_int16 | |
pypy/site-packages/astropy/io/fits/tests/test_checksum.py::TestChecksumFunctions::test_compressed_image_data_float32 | |
pypy/site-packages/astropy/io/fits/tests/test_core.py::TestCore::test_uint | |
/home/tom/pypy/site-packages/astropy/io/fits/hdu/hdulist.py:1186: VerifyWarning: Error validating header for HDU #2 (note: Astropy uses zero-based indexing). | |
I/O operation on closed file | |
There may be extra bytes after the last HDU or the file is corrupted. | |
len(self), indent(str(exc))), VerifyWarning) | |
pypy/site-packages/astropy/io/fits/tests/test_core.py::TestCore::test_consecutive_writeto | |
/home/tom/pypy/site-packages/astropy/io/fits/card.py:1151: ResourceWarning: unclosed file <_io.FileIO name='/home/tom/pypy/site-packages/astropy/io/fits/tests/data/blank.fits' mode='rb' closefd=True> | |
m = self._value_NFSC_RE.match(valuecomment) | |
pypy/site-packages/astropy/io/fits/tests/test_core.py::TestCore::test_consecutive_writeto | |
/home/tom/pypy/site-packages/astropy/io/fits/card.py:1151: ResourceWarning: unclosed file <_io.FileIO name='/home/tom/pypy/site-packages/astropy/io/fits/tests/data/tb.fits' mode='rb' closefd=True> | |
m = self._value_NFSC_RE.match(valuecomment) | |
pypy/site-packages/astropy/io/fits/tests/test_core.py::TestCore::test_consecutive_writeto | |
/home/tom/pypy/site-packages/astropy/io/fits/hdu/hdulist.py:1186: VerifyWarning: Error validating header for HDU #5 (note: Astropy uses zero-based indexing). | |
I/O operation on closed file | |
There may be extra bytes after the last HDU or the file is corrupted. | |
len(self), indent(str(exc))), VerifyWarning) | |
pypy/site-packages/astropy/io/fits/tests/test_fitstime.py::TestFitsTime::test_fits_to_time_meta[QTable] | |
/home/tom/pypy/site-packages/astropy/io/fits/card.py:775: ResourceWarning: unclosed file <_io.FileIO name='/tmp/fits-test-9ktq56fk/testb.fits' mode='rb' closefd=True> | |
numr = self._number_NFSC_RE.match(m.group('numr')) | |
pypy/site-packages/astropy/io/fits/tests/test_fitstime.py::TestFitsTime::test_fits_to_time_meta[QTable] | |
/home/tom/pypy/site-packages/astropy/io/fits/card.py:775: ResourceWarning: unclosed file <_io.FileIO name='/home/tom/pypy/site-packages/astropy/io/fits/tests/data/arange.fits' mode='rb' closefd=True> | |
numr = self._number_NFSC_RE.match(m.group('numr')) | |
pypy/site-packages/astropy/io/fits/tests/test_fitstime.py::TestFitsTime::test_fits_to_time_meta[QTable] | |
/home/tom/pypy/site-packages/astropy/io/fits/card.py:775: ResourceWarning: unclosed file <_io.FileIO name='/tmp/fits-test-gma8_hrz/testb.fits' mode='rb' closefd=True> | |
numr = self._number_NFSC_RE.match(m.group('numr')) | |
pypy/site-packages/astropy/io/fits/tests/test_fitstime.py::TestFitsTime::test_fits_to_time_meta[QTable] | |
/home/tom/pypy/site-packages/astropy/io/fits/card.py:775: ResourceWarning: unclosed file <_io.FileIO name='/tmp/fits-test-bc5wj_o1/testb.fits' mode='rb' closefd=True> | |
numr = self._number_NFSC_RE.match(m.group('numr')) | |
pypy/site-packages/astropy/io/fits/tests/test_fitstime.py::TestFitsTime::test_fits_to_time_meta[QTable] | |
/home/tom/pypy/site-packages/astropy/io/fits/card.py:775: ResourceWarning: unclosed file <_io.FileIO name='/tmp/fits-test-ffvw5e7v/testb.fits' mode='rb' closefd=True> | |
numr = self._number_NFSC_RE.match(m.group('numr')) | |
pypy/site-packages/astropy/io/fits/tests/test_fitstime.py::TestFitsTime::test_fits_to_time_meta[QTable] | |
/home/tom/pypy/site-packages/astropy/io/fits/card.py:775: ResourceWarning: unclosed file <_io.FileIO name='/tmp/fits-test-73vyvwyr/testb.fits' mode='rb' closefd=True> | |
numr = self._number_NFSC_RE.match(m.group('numr')) | |
pypy/site-packages/astropy/io/fits/tests/test_fitstime.py::TestFitsTime::test_fits_to_time_meta[QTable] | |
/home/tom/pypy/site-packages/astropy/io/fits/card.py:775: ResourceWarning: unclosed file <_io.FileIO name='/tmp/fits-test-5384opjo/testb.fits' mode='rb' closefd=True> | |
numr = self._number_NFSC_RE.match(m.group('numr')) | |
pypy/site-packages/astropy/io/fits/tests/test_fitstime.py::TestFitsTime::test_fits_to_time_meta[QTable] | |
/home/tom/pypy/site-packages/astropy/io/fits/card.py:775: ResourceWarning: unclosed file <_io.FileIO name='/tmp/fits-test-qrlv8i5n/testb.fits' mode='rb' closefd=True> | |
numr = self._number_NFSC_RE.match(m.group('numr')) | |
pypy/site-packages/astropy/io/fits/tests/test_fitstime.py::TestFitsTime::test_fits_to_time_meta[QTable] | |
/home/tom/pypy/site-packages/astropy/io/fits/card.py:775: ResourceWarning: unclosed file <_io.FileIO name='/tmp/fits-test-4df0_3ee/testb.fits' mode='rb' closefd=True> | |
numr = self._number_NFSC_RE.match(m.group('numr')) | |
pypy/site-packages/astropy/io/fits/tests/test_fitstime.py::TestFitsTime::test_fits_to_time_meta[QTable] | |
/home/tom/pypy/site-packages/astropy/io/fits/card.py:775: ResourceWarning: unclosed file <_io.FileIO name='/tmp/fits-test-vg1rz51x/testb.fits' mode='rb' closefd=True> | |
numr = self._number_NFSC_RE.match(m.group('numr')) | |
pypy/site-packages/astropy/io/fits/tests/test_fitstime.py::TestFitsTime::test_fits_to_time_meta[QTable] | |
/home/tom/pypy/site-packages/astropy/io/fits/card.py:775: ResourceWarning: unclosed file <_io.FileIO name='/tmp/fits-test-ojbin04c/testb.fits' mode='rb' closefd=True> | |
numr = self._number_NFSC_RE.match(m.group('numr')) | |
pypy/site-packages/astropy/io/fits/tests/test_fitstime.py::TestFitsTime::test_fits_to_time_meta[QTable] | |
/home/tom/pypy/site-packages/astropy/io/fits/card.py:775: ResourceWarning: unclosed file <_io.FileIO name='/tmp/fits-test-h3v6bwad/testb.fits' mode='rb' closefd=True> | |
numr = self._number_NFSC_RE.match(m.group('numr')) | |
pypy/site-packages/astropy/io/fits/tests/test_hdulist.py::TestHDUListFunctions::test_open_file_with_end_padding | |
/home/tom/Downloads/pypy3.6-7.2.0-linux_x86_64-portable/lib-python/3/ast.py:187: ResourceWarning: unclosed file <_io.FileIO name='/home/tom/pypy/site-packages/astropy/io/fits/tests/data/test0.fits' mode='rb' closefd=True> | |
for item in field: | |
pypy/site-packages/astropy/io/fits/tests/test_image.py::TestImageFunctions::test_fortran_array_non_contiguous | |
/home/tom/pypy/site-packages/_pytest/_code/source.py:294: ResourceWarning: unclosed file <_io.FileIO name='/tmp/fits-test-87wlnx15/test.fits' mode='rb' closefd=True> | |
for x in ast.walk(node): | |
pypy/site-packages/astropy/io/fits/tests/test_table.py::TestTableFunctions::test_numpy_ndarray_to_bintablehdu | |
/home/tom/Downloads/pypy3.6-7.2.0-linux_x86_64-portable/lib-python/3/ast.py:183: ResourceWarning: unclosed file <_io.FileIO name='/tmp/fits-test-2bfxsyk5/tmp.fits' mode='rb' closefd=True> | |
for name, field in iter_fields(node): | |
pypy/site-packages/astropy/io/fits/tests/test_table.py::TestTableFunctions::test_numpy_ndarray_to_bintablehdu | |
/home/tom/Downloads/pypy3.6-7.2.0-linux_x86_64-portable/lib-python/3/ast.py:183: ResourceWarning: unclosed file <_io.FileIO name='/tmp/fits-test-6hwrf8xy/tmp.fits' mode='rb' closefd=True> | |
for name, field in iter_fields(node): | |
pypy/site-packages/astropy/io/fits/tests/test_table.py::TestTableFunctions::test_numpy_ndarray_to_bintablehdu | |
/home/tom/Downloads/pypy3.6-7.2.0-linux_x86_64-portable/lib-python/3/ast.py:183: ResourceWarning: unclosed file <_io.FileIO name='/home/tom/pypy/site-packages/astropy/io/fits/tests/data/tb.fits' mode='rb' closefd=True> | |
for name, field in iter_fields(node): | |
pypy/site-packages/astropy/io/fits/tests/test_table.py::TestTableFunctions::test_numpy_ndarray_to_bintablehdu | |
/home/tom/Downloads/pypy3.6-7.2.0-linux_x86_64-portable/lib-python/3/ast.py:183: ResourceWarning: unclosed file <_io.FileIO name='/home/tom/pypy/site-packages/astropy/io/fits/tests/data/test0.fits' mode='rb' closefd=True> | |
for name, field in iter_fields(node): | |
pypy/site-packages/astropy/io/fits/tests/test_table.py::TestTableFunctions::test_numpy_ndarray_to_bintablehdu | |
/home/tom/Downloads/pypy3.6-7.2.0-linux_x86_64-portable/lib-python/3/ast.py:183: ResourceWarning: unclosed file <_io.FileIO name='/home/tom/pypy/site-packages/astropy/io/fits/tests/data/ascii.fits' mode='rb' closefd=True> | |
for name, field in iter_fields(node): | |
pypy/site-packages/astropy/stats/tests/test_biweight.py::test_biweight_location_masked | |
/home/tom/pypy/site-packages/numpy/ma/core.py:4596: ResourceWarning: unclosed <socket.socket fd=10, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 40747)> | |
result = self._data.reshape(*s, **kwargs).view(type(self)) | |
pypy/site-packages/astropy/wcs/tests/test_utils.py::test_noncelestial_scale[cdelt0-pc0-cd0] | |
pypy/site-packages/astropy/wcs/tests/test_utils.py::test_noncelestial_scale[cdelt1-pc1-cd1] | |
pypy/site-packages/astropy/wcs/tests/test_utils.py::test_noncelestial_scale[cdelt3-None-cd3] | |
/home/tom/pypy/site-packages/astropy/wcs/tests/test_utils.py:594: UserWarning: cdelt will be ignored since cd is present | |
mywcs.wcs.cdelt = cdelt | |
pypy/site-packages/astropy/wcs/tests/test_utils.py::test_noncelestial_scale[cdelt0-pc0-cd0] | |
pypy/site-packages/astropy/wcs/tests/test_utils.py::test_noncelestial_scale[cdelt1-pc1-cd1] | |
pypy/site-packages/astropy/wcs/tests/test_utils.py::test_noncelestial_scale[cdelt3-None-cd3] | |
/home/tom/pypy/site-packages/astropy/wcs/wcs.py:3081: UserWarning: cdelt will be ignored since cd is present | |
cdelt = np.dot(self.wcs.cd, np.diag(self.wcs.cdelt)) | |
pypy/site-packages/astropy/wcs/tests/test_wcsprm.py::test_sub_segfault | |
/home/tom/pypy/lib-python/3/importlib/_bootstrap.py:177: ResourceWarning: unclosed file <_io.FileIO name='/home/tom/pypy/site-packages/astropy/wcs/tests/data/validate.fits' mode='rb' closefd=True> | |
_imp.acquire_lock() | |
-- Docs: https://docs.pytest.org/en/latest/warnings.html | |
= 274 failed, 12242 passed, 1072 skipped, 52 xfailed, 38 warnings in 270.15s (0:04:30) = |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment