CityofToronto / bdit_traffic_prophet

Suite of algorithms for predicting average daily traffic on Toronto streets
GNU General Public License v3.0
1 stars 1 forks source link

Metaclass factory to replace Registrar and registry access classes #40

Open cczhu opened 4 years ago

cczhu commented 4 years ago

We currently use Registrar metaclasses to register different analysis classes in CountMatch. There are multiple metaclasses, but all share nearly identical codebases, so it would be ideal to be able to write something like

DV_REGISTRY = {}
"""Dict for storing derived value processor class definitions."""

DVRegistrar = RegistrarFactory(DV_REGISTRY, "DV_REGISTRY", "_dv_type")

in place of the current DVRegistrar definition.

Ditto for DerivedVals:

DerivedVals = RegistryAccess(DV_REGISTRY)

Tests should remain the same, since the functionality is identical. Thus, very little effort wasted when writing tests currently.

cczhu commented 4 years ago

Also, in the tests, move Registrar class tests into the same class as launcher tests.

cczhu commented 4 years ago

Also, the neighbour module needs a metaclass registrar and a functional wrapper for initializing nearest neighbour calculator instances.

Once you've built this registrar, change the relevant test fixtures and preprocessing functions in test_matcher.py as well.