Navigation Menu

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

Add unit tests for ISIS_Powder common routines #19163

Merged
merged 25 commits into from Apr 21, 2017

Conversation

DavidFair
Copy link
Contributor

@DavidFair DavidFair commented Mar 16, 2017

Must not be merged before #19112 - I would recommend waiting for that PR before taking this one so you can get an accurate diff

Description of work.
This PR adds unit tests for the common functions in the ISIS_Powder scripts

To test:
Check that unit tests pass
Code review

Fixes #19113 .

Does not need to be in the release notes.


Reviewer

Please comment on the following (full description):

Code Review
  • Is the code of an acceptable quality?
  • Does the code conform to the coding standards? Is it well structured with small focussed classes/methods/functions?
  • Are there unit/system tests in place? Are the unit tests small and test the a class in isolation?
  • If there are changes in the release notes then do they describe the changes appropriately?
Functional Tests
  • Do changes function as described? Add comments below that describe the tests performed?

  • How do the changes handle unexpected situations, e.g. bad input?

  • Has the relevant documentation been added/updated?

  • Is user-facing documentation written in a user-friendly manner?

  • Has developer documentation been updated if required?

  • Does everything look good? Comment with the ship it emoji but don't merge. A member of @mantidproject/gatekeepers will take care of it.

@DavidFair DavidFair added Component: Python Powder Issues and pull requests related to powder diffraction labels Mar 16, 2017
@DavidFair DavidFair added this to the Release 3.10 milestone Mar 16, 2017
@DavidFair DavidFair mentioned this pull request Mar 20, 2017
9 tasks
@dtasev dtasev self-assigned this Mar 22, 2017
@@ -65,9 +65,9 @@ def update_attributes(self, advanced_config=None, basic_config=None, kwargs=None
self._parse_attributes(self._adv_config_dict, suppress_warnings=suppress_warnings)
if advanced_config or basic_config:
self._parse_attributes(self._basic_conf_dict,
suppress_warnings=(not bool(basic_config or suppress_warnings)))
suppress_warnings=(not bool(basic_config) or suppress_warnings))
Copy link
Contributor

Choose a reason for hiding this comment

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

More of a query than a note, do we have to cast implicitly to bool? I think it's done automatically when you put the not in front, i.e. there shouldn't be a difference between not bool(basic_config) and just not basic_config

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point Python does this implicitly I'll change that in the current branch I'm working on (to reduce the number of merge conflict in the future)

Copy link
Contributor

Choose a reason for hiding this comment

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

bump to remove bool, unit tests passed

@dtasev
Copy link
Contributor

dtasev commented Mar 24, 2017

From a brief look changes look good, all the unit tests pass, I'll have a look again after #19112 is merged and mark for ship then

if advanced_config or basic_config or kwargs:
self._parse_attributes(self._kwargs, suppress_warnings=(not bool(kwargs or suppress_warnings)))
self._parse_attributes(self._kwargs, suppress_warnings=(not bool(kwargs)) or suppress_warnings)
Copy link
Contributor

Choose a reason for hiding this comment

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

(not bool(kwargs)) or suppress_warnings)
is the 2nd bracket after kwargs a mistake?

@@ -65,9 +65,9 @@ def update_attributes(self, advanced_config=None, basic_config=None, kwargs=None
self._parse_attributes(self._adv_config_dict, suppress_warnings=suppress_warnings)
if advanced_config or basic_config:
self._parse_attributes(self._basic_conf_dict,
suppress_warnings=(not bool(basic_config or suppress_warnings)))
suppress_warnings=(not bool(basic_config) or suppress_warnings))
Copy link
Contributor

Choose a reason for hiding this comment

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

bump to remove bool, unit tests passed

"This should be a range of runs in this cycle in the mapping file."
" Please check your indentation if this should be within a cycle.")
"This should be a range of runs in the mapping file."
" Please check your indentation if the syntax looks correct.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Please check your indentation if the syntax looks correct. consider rephrasing to something like
Please check your indentation and make sure that the syntax is correct.

@@ -156,7 +157,10 @@ def get_first_run_number(run_number_string):
:return: The first run for the user input of runs
"""
run_numbers = generate_run_numbers(run_number_string=run_number_string)
return run_numbers[0]
if isinstance(run_numbers, list):
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like generate_run_numbers always returns a list, with single run number, or a range

Copy link
Contributor

Choose a reason for hiding this comment

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

also in get_monitor_ws here, I think you could use get_first_run_number

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thats correct - it means the caller doesn't have to figure out types on their end (e.g. can just use a for in loop or [0])

Good spot 👍

@dtasev
Copy link
Contributor

dtasev commented Apr 5, 2017

Use get_first_run_number in yaml_parser.py here ?

@dtasev
Copy link
Contributor

dtasev commented Apr 19, 2017

:shipit: when OSX build lands on a node which has yaml installed

@SimonHeybrock SimonHeybrock merged commit eb80002 into master Apr 21, 2017
@SimonHeybrock SimonHeybrock deleted the 19113_add_unit_tests_ISIS_Powder_common branch April 21, 2017 12:46
@DavidFair DavidFair moved this from PR to Done in ISIS Powder Diffraction Apr 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Powder Issues and pull requests related to powder diffraction
Development

Successfully merging this pull request may close these issues.

None yet

3 participants