Split pro forma module into multiple classes #26
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR partly addresses #17 and is purely an improvement to readability and maintainability, basically by refactoring the module into smaller chunks of code.
The main change is to create two new classes:
SqFtProFormaReference
class now handles all of the_generate_lookup
code, which creates the reference tables (which create some metrics for each floor-to-area ratio, for each form and parking configuration) the the lookup method eventually uses. The main class generates this object and saves the tables upon instantiation (here).SqFtProFormaLookup
class now handles all of the lookup code which actually returns the feasibility results. The main class just creates an object of this class and calls its lookup method.Within each of these classes, I’ve moved some code out of long methods into their own helper methods wherever it seemed to make sense. For example:
SqFtProFormaReference
class, the_building_bulk
,_park_sqft
, and_stories
helper methods were all part of the original_generate_lookup
method. Note that I also started to try and refer to this as the “reference” table to disambiguate from the “lookup” method later (both were referred to as “lookup” earlier)._simple_zoning
were split out of the lookup method.A couple more minor things:
np.reshape(data, (-1,1))
code that was in several places was a little confusing so I made a small utility function calledcolumnize
that hopefully makes the code more readable.