def test_band_dimension_rename_labels_with_source_mismatch(): b02 = Band("B02", "blue", 0.490) b03 = Band("B03", "green", 0.560) bdim = BandDimension(name="bs", bands=[b02, b03]) metadata = CollectionMetadata({}, dimensions=[bdim]) with pytest.raises(ValueError, match="should have same number of labels, but got"): _ = metadata.rename_labels("bs", target=['2', "3"], source=['B03'])
def test_band_dimension_set_labels(): bdim = BandDimension(name="bs", bands=[Band('some_name',None,None)]) metadata = CollectionMetadata({},dimensions=[bdim]) newdim = metadata.rename_labels("bs",target=['1','2','3']).band_dimension assert metadata.band_dimension.band_names == ['some_name'] assert newdim.band_names == ['1','2','3']
def test_band_dimension_rename_labels(): b02 = Band("B02", "blue", 0.490) b03 = Band("B03", "green", 0.560) b04 = Band("B04", "red", 0.665) bdim = BandDimension(name="bs", bands=[b02, b03, b04]) metadata = CollectionMetadata({},dimensions=[bdim]) newdim = metadata.rename_labels("bs",target=['1','2','3']).band_dimension assert metadata.band_dimension.band_names == ['B02','B03','B04'] assert newdim.band_names == ['1','2','3']