File: test_empty_slice.py

package info (click to toggle)
python-fitsio 1.3.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,020 kB
  • sloc: python: 7,963; ansic: 3,962; makefile: 10
file content (20 lines) | stat: -rw-r--r-- 509 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import tempfile
import os
import numpy as np
from ..fitslib import write, FITS


def test_empty_image_slice():
    shape = (10, 10)
    data = np.arange(shape[0] * shape[1]).reshape(shape)

    with tempfile.TemporaryDirectory() as tmpdir:
        fname = os.path.join(tmpdir, 'test.fits')
        write(fname, data, clobber=True)

        with FITS(fname) as fits:
            assert fits[0][0:0, 0:0].size == 0

            assert fits[0][0:8, 0:0].size == 0

            assert fits[0][0:0, 0:8].size == 0