def test_simple_aperture(r): data = np.ones((10, 10)) res = aperture_photometry(data, [5], [5], r=r, r_ann=None) assert_equal(res['x'], [5]) assert_equal(res['y'], [5]) assert_equal(res['aperture'], [r]) assert_almost_equal(res['flux'], [np.pi * r**2]) assert_not_in('sky', res.colnames) assert_almost_equal(res['flux_error'], [np.sqrt(np.pi * r**2)]) assert_equal(res['flags'], [0])
def test_simbad_catalog_get_simbad(self): # must be free of fluxdata s = self.cat.get_simbad() assert_is_instance(s, Simbad.__class__) for i in s.get_votable_fields(): assert_not_in('fluxdata', i) # must contain flux data s = self.cat.get_simbad(band='V') assert_is_instance(s, Simbad.__class__) assert_in('fluxdata(V)', s.get_votable_fields())
def test_extract_header_nosip(self): header = fits.Header.fromstring(_base_header + _wcs_no_sip, sep='\n') h, wcs = extract_header_wcs(header) assert_is_instance(wcs, WCS) assert_equal(wcs.wcs.ctype[0], 'RA---TAN') assert_equal(wcs.wcs.ctype[1], 'DEC--TAN') assert_is_instance(h, fits.Header) for i in _comon_wcs_keys: assert_not_in(f'{i}1', h.keys()) assert_not_in(f'{i}2', h.keys()) assert_in('DATE-OBS', h.keys()) assert_false(h is header) assert_not_equal(h, header)
def test_assert_not_in(self): assert_not_in(6, [1, 2, 3, 4, 5]) assert_not_in('d', 'abc') with pytest.raises(AssertionError): assert_not_in('a', 'abc') with pytest.raises(AssertionError): assert_not_in(2, [2, 3, 4])
def test_logger_remove_handler(): mylog = logger.getChild('testing') msg = 'Some error happend here.' logs = [] lh = log_to_list(mylog, logs) mylog.setLevel('DEBUG') mylog.error(msg) assert_is_instance(lh, ListHandler) assert_in(lh, mylog.handlers) mylog.removeHandler(lh) assert_not_in(lh, mylog.handlers) assert_equal(logs[0], msg) assert_equal(lh.log_list[0], msg) assert_equal(lh.log_list, logs)
def test_framemeta_popitem(self): a = FrameMeta({'A': 1, 'B': 2, 'c': 3}) assert_equal(a.popitem('a'), ('a', 1)) assert_not_in('a', a) assert_equal(a.popitem('a'), ('a', None))
def test_framemeta_pop(self): a = FrameMeta({'A': 1, 'b': 'test', 'TesT': 'AaA'}) res = a.pop('test') assert_equal(res, 'AaA') assert_not_in('test', a.keys()) assert_not_in('TesT', a.keys())