parameters: (self, **kwargs)
docstring: Calculate the Schwartzberg measure of compactness.
  
          @keyword district: A L{District} whose compactness should be
              computed.
          @keyword plan: A L{Plan} whose district compactnesses should be
              averaged.
          @keyword version: Optional. The version of the plan, defaults to
              the most recent version.
docstring_summary: Calculate the Schwartzberg measure of compactness.
docstring_tokens: Calculate the Schwartzberg measure of compactness .
function: def compute(self, **kwargs):
          """
          Calculate the Schwartzberg measure of compactness.
  
          @keyword district: A L{District} whose compactness should be
              computed.
          @keyword plan: A L{Plan} whose district compactnesses should be
              averaged.
          @keyword version: Optional. The version of the plan, defaults to
              the most recent version.
          """
          districts = []
          if 'district' in kwargs:
              districts = [kwargs['district']]
              if districts[0].geom.empty:
                  return
  
          elif 'plan' in kwargs:
              plan = kwargs['plan']
              version = kwargs[
                  'version'] if 'version' in kwargs else plan.version
              districts = plan.get_districts_at_version(
                  version, include_geom=True)
  
          else:
              return
  
          num = 0
          compactness = 0
          for district in districts:
              if district.district_id == 0:
                  continue
  
              if district.geom.empty:
                  continue
  
              if district.geom.length == 0:
                  continue
  
              r = sqrt(district.geom.area / pi)
              circumference = 2 * pi * r
              compactness += circumference / district.geom.length
              num += 1
  
          self.result = {'value': (compactness / num) if num > 0 else 0}
function_tokens: def compute ( self , * * kwargs ) : districts = [ ] if 'district' in kwargs : districts = [ kwargs [ 'district' ] ] if districts [ 0 ] . geom . empty : return elif 'plan' in kwargs : plan = kwargs [ 'plan' ] version = kwargs [ 'version' ] if 'version' in kwargs else plan . version districts = plan . get_districts_at_version ( version , include_geom = True ) else : return num = 0 compactness = 0 for district in districts : if district . district_id == 0 : continue if district . geom . empty : continue if district . geom . length == 0 : continue r = sqrt ( district . geom . area / pi ) circumference = 2 * pi * r compactness += circumference / district . geom . length num += 1 self . result = { 'value' : ( compactness / num ) if num > 0 else 0 }