def test_duplicate_parameter(self):

        imdata = np.arange(100.0)
        imdata.shape = (10, 1, 1, 2, 5)
        pdata1 = np.arange(10, dtype=np.float32) + 1
        pdata2 = 42.0
        x = fits.hdu.groups.GroupData(imdata, parnames=['abc', 'xyz', 'abc'],
                                      pardata=[pdata1, pdata2, pdata1],
                                      bitpix=-32)

        assert x.parnames == ['abc', 'xyz', 'abc']
        assert (x.par('abc') == pdata1 * 2).all()
        assert x[0].par('abc') == 2

        # Test setting a parameter
        x[0].setpar(0, 2)
        assert x[0].par('abc') == 3
        assert_raises(ValueError, x[0].setpar, 'abc', 2)
        x[0].setpar('abc', (2, 3))
        assert x[0].par('abc') == 5
        assert x.par('abc')[0] == 5
        assert (x.par('abc')[1:] == pdata1[1:] * 2).all()

        # Test round-trip
        ghdu = fits.GroupsHDU(data=x)
        ghdu.writeto(self.temp('test.fits'))

        with fits.open(self.temp('test.fits')) as h:
            hdr = h[0].header
            assert hdr['PCOUNT'] == 3
            assert hdr['PTYPE1'] == 'abc'
            assert hdr['PTYPE2'] == 'xyz'
            assert hdr['PTYPE3'] == 'abc'
            assert x.parnames == ['abc', 'xyz', 'abc']
            assert x.dtype.names == ('abc', 'xyz', '_abc', 'DATA')
            assert x.par('abc')[0] == 5
            assert (x.par('abc')[1:] == pdata1[1:] * 2).all()
Service available?
dataset/ETHPy150Open spacetelescope/PyFITS/pyfits/tests/test_groups.py/TestGroupsFunctions.test_duplicate_parameter--crossover with--dataset/ETHPy150Open benoitc/dj-webmachine/webmachine/decisions.py/b13