-
Notifications
You must be signed in to change notification settings - Fork 49
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
Remove most use of literal lists of simulators. #200
Conversation
could exist, and support for producing the list of simulators. Use this in place of hardcoded lists of simulators.
Codecov Report
@@ Coverage Diff @@
## develop #200 +/- ##
===========================================
+ Coverage 81.57% 81.66% +0.08%
===========================================
Files 38 39 +1
Lines 2709 2722 +13
Branches 342 344 +2
===========================================
+ Hits 2210 2223 +13
Misses 392 392
Partials 107 107
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much cleaner, thanks!
pocs/hardware.py
Outdated
ALL_NAMES = sorted(['camera', 'dome', 'mount', 'night', 'weather']) | ||
|
||
|
||
def GetAllNames(all_names=ALL_NAMES, without=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_all_names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
pocs/hardware.py
Outdated
def GetAllNames(all_names=ALL_NAMES, without=None): | ||
""" | ||
""" | ||
if without: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you change the default to be without=list()
then you don't need to check for the if
and you can just do the one line return statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
pocs/hardware.py
Outdated
return list(all_names) | ||
|
||
|
||
def GetSimulatorNames(simulator=None, kwargs=None, config=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_simulator_names
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
pocs/hardware.py
Outdated
Or: | ||
GetSimulatorNames(simulator=simulator, config=self.config) | ||
|
||
The reason this function doesn't just take **kwargs as its sole arg is that we need to allow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't doubt this is true but seems odd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annoying but true.
pocs/hardware.py
Outdated
List of names of the hardware to be simulated. | ||
""" | ||
def ExtractSimulator(d): | ||
if d: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep meaning to mention this in other places, but the more pythonic way (EAFP) would be to:
try:
return d['simulator']
except KeyError:
return None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided on yet another approach.
pocs/hardware.py
Outdated
if d: | ||
return d.get('simulator') | ||
return None | ||
for simulator in [simulator, ExtractSimulator(kwargs), ExtractSimulator(config)]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems odd to reuse simulator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed... and what a stupid idea! Clearly a sign that I added the simulator kwarg after deciding that the for loop variable would be called simulator.
pocs/hardware.py
Outdated
Returns: | ||
List of names of the hardware to be simulated. | ||
""" | ||
def ExtractSimulator(d): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract_simulator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meant to mark Request Changes for the CamelCase names.
Add pocs/hardware.py, with info about all the types of hardware that could exist, and support for producing the list of simulators. Use this in place of hardcoded lists of simulators.
Supports #134 and #199, but does not fix either one.