metawards.WardInfos

class metawards.WardInfos(wards: List[metawards._wardinfo.WardInfo] = <factory>, _index: Dict[metawards._wardinfo.WardInfo, int] = None)[source]

Simple class that holds a list of WardInfo objects, and provides useful search functions over that list. This prevents me from cluttering up the interface of Network

__init__(wards: List[metawards._wardinfo.WardInfo] = <factory>, _index: Dict[metawards._wardinfo.WardInfo, int] = None) → None

Initialize self. See help(type(self)) for accurate signature.

Methods

__contains__(info)

Return whether or not this contains the passed WardInfo

__delattr__(name, /)

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__(other)

Return self==value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__getitem__(index)

__gt__(value, /)

Return self>value.

__init__([wards, _index])

Initialize self.

__init_subclass__

This method is called when a class is subclassed.

__le__(value, /)

Return self<=value.

__len__()

__lt__(value, /)

Return self<value.

__ne__(value, /)

Return self!=value.

__new__(**kwargs)

Create and return a new object.

__reduce__()

Helper for pickle.

__reduce_ex__(protocol, /)

Helper for pickle.

__repr__()

Return repr(self).

__setattr__(name, value, /)

Implement setattr(self, name, value).

__setitem__(i, info)

Set the ith WardInfo equal to ‘info’.

__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

__subclasshook__

Abstract classes can override this to customize issubclass().

_find_authority(name, match)

Internal function that flexibly finds a ward by authority

_find_region(name, match)

Internal function that flexibly finds a ward by region

_find_ward(name, match, include_alternates)

Internal function that flexibly finds a ward by name

_intersect(list1, list2)

Return the intersection of two lists

contains(info)

Return whether or not this contains the passed WardInfo

find([name, authority, region, match, …])

Generic search function that will search using any or all of the terms provided.

index(info)

Return the index of the passed ‘info’ object if it is in this list.

reindex()

Rebuild the WardInfo index.

Attributes

__annotations__

__dataclass_fields__

__dataclass_params__

__dict__

__doc__

__hash__

__module__

__weakref__

list of weak references to the object (if defined)

_index

The index used to speed up lookup of wards

__contains__(info: metawards._wardinfo.WardInfo) → bool[source]

Return whether or not this contains the passed WardInfo

__setitem__(i: int, info: metawards._wardinfo.WardInfo) → None[source]

Set the ith WardInfo equal to ‘info’.

contains(info: metawards._wardinfo.WardInfo) → bool[source]

Return whether or not this contains the passed WardInfo

find(name: str = None, authority: str = None, region: str = None, match: bool = False, match_authority_and_region: bool = False, include_alternates: bool = True)[source]

Generic search function that will search using any or all of the terms provided. This returns a list of indicies of wards that match the search

Parameters
  • name (str or regexp) – Name or code of the ward to search. You can also include the authority adn region by separating usign “/”, e.g. “Clifton/Bristol”.

  • authority (str or regexp) – Name or code of the authority to search

  • region (str or regexp) – Name or code of the region to search

  • match (bool(False)) – Use a regular expression match for the ward rather than a search. This forces the match to be at the start of the string

  • match_authority_and_region (bool(False)) – Use a regular expression match for the authority and region rather than a search. This forces the match to be at the start of the string

  • include_alternates (bool(True)) – Whether or not to include alternative names and codes when searching for the ward

index(info: metawards._wardinfo.WardInfo) → int[source]

Return the index of the passed ‘info’ object if it is in this list. If not, then a ValueError exception is raised. Note that only the first matching WardInfo will be returned

reindex()[source]

Rebuild the WardInfo index. You must call this function after you have modified the list of WardInfo objects, as otherwise this will fall out of date. Note that this will be automatically called the first time you use the “contains” or “index” functions

wards: List[metawards._wardinfo.WardInfo]

The list of WardInfo objects, one for each ward in order