def __init__(self, parcels): self.offset = defaultdict(lambda x: 0) self.residential_parcels = defaultdict(lambda x: []) self.commercial_parcels = defaultdict(lambda x: []) self.default_parcels = {} self.other_parcels = defaultdict(lambda x: []) for apn, maz, kind in parcels: if kind == 'residential': self.residential_parcels[maz].append(Parcel(apn)) elif kind == 'commercial': self.commercial_parcels[maz].append(Parcel(apn)) elif kind == 'default': self.default_parcels[maz] = Parcel(apn) elif kind == 'other': self.other_parcels[maz].append(Parcel(apn)) self.residential_parcels.lock() self.commercial_parcels.lock() self.other_parcels.lock() self.mazs = set(self.default_parcels.keys())
def load_parcels(self): parcels = self.fetch_parcels() self.residential_parcels = defaultdict(lambda x: []) self.commercial_parcels = defaultdict(lambda x: []) self.default_parcels = {} self.other_parcels = defaultdict(lambda x: []) for apn, maz, kind in counter(parcels, 'Loading parcel %s.'): if kind == 'residential': self.residential_parcels[maz].append(Parcel(apn)) elif kind == 'commercial': self.commercial_parcels[maz].append(Parcel(apn)) elif kind == 'default': self.default_parcels[maz] = Parcel(apn) elif kind == 'other': self.other_parcels[maz].append(Parcel(apn)) self.residential_parcels.lock() self.commercial_parcels.lock() self.other_parcels.lock() self.mazs = set(self.default_parcels.keys()) self.offset = defaultdict(lambda x: 0)
def load_temperatures(self, kind: str = 'mrt'): log.info('Loading network air temperature data.') query = ''' SELECT temperature_id, temperature_idx, temperature FROM air_temperatures; ''' self.database.cursor.execute(query) rows = self.database.fetch_rows() temps = defaultdict(lambda: [None]*96) rows = counter(rows, 'Loading air temperature %s.') for temperature_id, temperature_idx, temperature in rows: temps[temperature_id][temperature_idx] = temperature for uuid, values in temps.items(): self.air_temperatures[uuid] = Temperature(uuid, values) log.info('Loading network mrt temperature data.') query = f''' SELECT temperature_id, temperature_idx, {kind} FROM mrt_temperatures; ''' self.database.cursor.execute(query) rows = self.database.cursor.fetchall() temps = defaultdict(lambda: [None]*96) rows = counter(rows, 'Loading mrt temperature %s.') for temperature_id, temperature_idx, temperature in rows: temps[temperature_id][temperature_idx] = temperature for uuid, values in temps.items(): self.mrt_temperatures[uuid] = Temperature(uuid, values)
def __init__(self, database: SqliteUtil): self.database = database self.temperatures = defaultdict(lambda x: []) self.centroids: Dict[str, Centroid] = {} self.links: Dict[str, Link] = {} self.nodes: Dict[str, Node] = {}
def __init__(self, database: 'SqliteUtil'): self.database = database self.links = {} self.nodes = {} self.agents = defaultdict(lambda uuid: Agent(uuid))
def __init__(self, database): self.database = database self.legs = defaultdict(lambda x: []) self.activities = defaultdict(lambda x: [])
def __init__(self): self.households = defaultdict(lambda x: Household(x)) self.last_trip = None
def __init__(self): self.households: Dict[int, Household] = defaultdict(lambda x: Household(x)) self.last_trip: Trip = None