Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor code to support custom calculators #283

Merged
merged 20 commits into from
Nov 19, 2021

Conversation

mreveil
Copy link
Contributor

@mreveil mreveil commented Nov 16, 2021

Extract all close contacts calculations from main Simulation class into a custom calculator class. Support the usage of any custom user-provided calculator that subclasses a new abstract Calculator class.

@mreveil mreveil changed the title [WIP] Support custom calculator part3 [WIP] Refactor code to support custom calculator Nov 16, 2021
@mreveil mreveil changed the title [WIP] Refactor code to support custom calculator [WIP] Refactor code to support custom calculators Nov 16, 2021
@mreveil mreveil requested a review from amjha November 19, 2021 15:33
@mreveil mreveil changed the title [WIP] Refactor code to support custom calculators Refactor code to support custom calculators Nov 19, 2021

for key, v in contacts_per_coord.items():
x, y = key
color = color_scale(1.0 - v * 1.0 / max_contacts)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential divide by zero exception here if max_contacts is not updated in if block at line# 344

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually correct. If max_contacts is zero, this means there was no contact which in turn means contacts_per_coord will be empty and therefore the loop will not be executed.

@amjha amjha merged commit 51676fe into release/0.15 Nov 19, 2021
@amjha amjha deleted the support-custom-calculator-part3 branch November 19, 2021 19:32
@mreveil mreveil restored the support-custom-calculator-part3 branch November 25, 2021 04:03
amjha added a commit that referenced this pull request Apr 12, 2022
* added error message

* Refactor to support custom calculator-part1 (#278)

* Change policy submodule name to schedulers

* Rename daily_schedule.py to schedule.py

* Update index.js

Removed console log statement.

* Refactor code to support custom schedulers (#281)

* Change policy submodule name to schedulers

* Rename daily_schedule.py to schedule.py

* create new OfficeScheduler and EmployeeSchedule classes

* Rename employee schedule to office schedule

* Rename MeetingPolicy to MeetingSchedule. Add missing docstrings.

* Update unit tests and fix failing tests

* Fix linting issues

* No more circular imports...yay!

* Update tests and fix issues from review

* Remove unnecessary exception

* Fix linting issues

* Refactor code to support custom calculators (#283)

* Change policy submodule name to schedulers

* Rename daily_schedule.py to schedule.py

* create new OfficeScheduler and EmployeeSchedule classes

* Rename employee schedule to office schedule

* Rename MeetingPolicy to MeetingSchedule. Add missing docstrings.

* Update unit tests and fix failing tests

* Fix linting issues

* No more circular imports...yay!

* Update tests and fix issues from review

* Remove unnecessary exception

* Fix linting issues

* Move close contacts computation to custom calculator class

* Update simulation unit tests

* Update close contacts unit tests

* Fix contacts per coord unit test

* Fix linting issues

* Fix broken unit tests

* Fix linting issues

* delete package-lock.json

* added Policy info to home page

* Update the Simulation class to support custom applications (#286)

* Update simulation class to support custom calculator and scheduler

* Fix linting issues

* redesined ui - pending load trajectory

* load trajectory on button click

* code cleanup

* updated css layout

* Update footer for copyright year

* Fix bug with issue loader showing up when sim changes.

* Fix doc link and update policy details automatically

* Remove unnecessary vue files

* Reload trajectory and map data when new simulation is selected.

* Fix double scrollbar issue

* Fix map sizing and remove old test files

* Revert "Fix map sizing and remove old test files"

This reverts commit b86ae1b.

* Remove unnecessary js tests

* Add passWithNoTests to JS tests.

* Check black's version and output diffs

* Fix black issues + line sizing in map

* Output vue version used for linting

* Check vue version before linting

* Update vue-cli version in package.json

* Remove check for vue version

* Check eslint version

* Remove check for eslint version

* Fix js linting issue (finally!)

* Updated docs for release/0.15 (#292)

* Add full example simulation and simplify README

* Look in current directory for facility data

* Remove manual ToC

* Remove obsolete info

* Reformat files with black

* Reformat files with black - part2

It seems black changed their formatting rules in their new version. Pretty much all the python files are reformatted.

* Fix python linting

* Stop tracking package-lock.json

* Updated copyright & simpler install from source

Co-authored-by: Amit Jha <JhaA2@corning.com>
Co-authored-by: Modini <ModiniK@corning.com>
Co-authored-by: amjha <amitjha@usc.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants