code: def filter(self, sites, rupture):
          
          distances = get_distances(rupture, sites, self.filter_distance)
          if self.maximum_distance:
              mask = distances <= self.maximum_distance(
                  rupture.tectonic_region_type, rupture.mag)
              if mask.any():
                  sites, distances = sites.filter(mask), distances[mask]
              else:
                  raise FarAwayRupture(
                      '%d: %d km' % (rupture.serial, distances.min()))
          return sites, DistancesContext([(self.filter_distance, distances)])
docs: Filter the site collection with respect to the rupture.
  
          :param sites:
              Instance of :class:`openquake.hazardlib.site.SiteCollection`.
          :param rupture:
              Instance of
              :class:`openquake.hazardlib.source.rupture.BaseRupture`
          :returns:
              (filtered sites, distance context)