def test_fg_filtered_empty(self, tmpdir): tmpdir, flist = tmpdir fg = FitsFileGroup(location=tmpdir / 'fits', compression=False) # non existing key nfg = fg.filtered({'NON-EXISTING': 1}) assert_is_instance(nfg, FitsFileGroup) assert_equal(len(nfg), 0) assert_equal(nfg.files, []) # existing but not matched nfg = fg.filtered({'object': 'Sun'}) assert_is_instance(nfg, FitsFileGroup) assert_equal(len(nfg), 0) assert_equal(nfg.files, [])
def test_fg_filtered_multiple_key(self, tmpdir): tmpdir, flist = tmpdir fg = FitsFileGroup(location=tmpdir / 'fits', compression=False) nfg = fg.filtered({ 'object': 'Moon', 'exptime': 1.0, 'image': 'object_4_v.fits' }) assert_equal(len(nfg), 1) assert_equal(nfg.files, [flist['fits'][24]])
def test_fg_filtered_single_key(self, tmpdir): tmpdir, flist = tmpdir fg = FitsFileGroup(location=tmpdir / 'fits', compression=False) bias_files = flist['fits'][:10] flat_files = flist['fits'][10:20] sci_files = flist['fits'][20:] # object keyword fg_b = fg.filtered({'object': 'bias'}) assert_equal(len(fg_b), 10) assert_equal(sorted(fg_b.files), sorted(bias_files)) # filter keyword fg_v = fg.filtered({'filter': 'V'}) assert_equal(len(fg_v), 20) assert_equal(sorted(fg_v.files), sorted(flat_files + sci_files)) # Hierarch key with space fg_s = fg.filtered({'space key': 1}) assert_equal(len(fg_s), 30) assert_equal(sorted(fg_s.files), sorted(bias_files + flat_files + sci_files))