code: def measure(self, geometry):
          
          message = 'Size with NaN value : geometry valid={valid}, WKT={wkt}'
          feature_size = 0
          if geometry.isMultipart():
              # Be careful, the size calculator is not working well on a
              # multipart.
              # So we compute the size part per part. See ticket #3812
              for single in geometry.asGeometryCollection():
                  if self.geometry_type == QgsWkbTypes.LineGeometry:
                      geometry_size = self.calculator.measureLength(single)
                  else:
                      geometry_size = self.calculator.measureArea(single)
                  if not isnan(geometry_size):
                      feature_size += geometry_size
                  else:
                      LOGGER.debug(message.format(
                          valid=single.isGeosValid(),
                          wkt=single.asWkt()))
          else:
              if self.geometry_type == QgsWkbTypes.LineGeometry:
                  geometry_size = self.calculator.measureLength(geometry)
              else:
                  geometry_size = self.calculator.measureArea(geometry)
              if not isnan(geometry_size):
                  feature_size = geometry_size
              else:
                  LOGGER.debug(message.format(
                      valid=geometry.isGeosValid(),
                      wkt=geometry.asWkt()))
  
          feature_size = round(feature_size)
  
          if self.output_unit:
              if self.output_unit != self.default_unit:
                  feature_size = convert_unit(
                      feature_size, self.default_unit, self.output_unit)
  
          return feature_size
docs: Measure the length or the area of a geometry.
  
          :param geometry: The geometry.
          :type geometry: QgsGeometry
  
          :return: The geometric size in the expected exposure unit.
          :rtype: float