District

District

District defines a district and and the precincts it contains.

class distopia.district.District(**kwargs)[source]

Describes a district, its precincts and its metrics.

add_precinct(precinct)[source]

Adds a precinct to the district.

Parameters

precinctPrecinct instance.

assign_precincts(precincts)[source]

Adds the precincts to the district.

Parameters

precincts – Iterable of Precinct instances.

boundary = []

A list of the x, y coordinates of the polygon that describes the district’s boundary.

clear()[source]

Clears all the existing precincts from the district.

identity = 0

The id of the district.

metrics = {}

A mapping from name to the DistrictMetric instance that contains the summery metric data for this district.

name = ''

A globally unique name (or number) describing the district.

neighbours = []

List of other District’s that are on the boundary of this district.

precincts = []

List of Precinct instances that are currently contained within this district.

District Metrics

Defines metrics that summarize the district based on the contained precincts and other metadata.

class distopia.district.metrics.DistrictMetric(name, **kwargs)[source]

Metrics used with distopia.district.District.

name = ''

A globally unique metric name that describes the metric.

class distopia.district.metrics.DistrictAggregateMetric(district, **kwargs)[source]
class distopia.district.metrics.DistrictHistogramAggregateMetric(district, **kwargs)[source]
class distopia.district.metrics.DistrictScalarMetric(district, **kwargs)[source]