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

Unit tests for untested methods of tardis/util.py #507

Merged
merged 13 commits into from
Nov 11, 2016

Conversation

kdexd
Copy link

@kdexd kdexd commented Mar 5, 2016

This PR will be consisting a series of commits targetting to improve code coverage of tardis/utils.py.

This checklist maintains the methods/ classes present in tardis/utils.py on 05 March 2016, the day when #506 was created. The commits enclosed in brackets show where these tests were modified/ added.

- Three new methods introduced in test_util.py, of
  them the first method tests MalformedSpeciesError,
  second method tests MalformedElementsSymbolError,
  third method tests MalformedQuantityError.

- All 3 classes inherit from an empty MalformedError
  so MalformedError itself does not need unit test.
@kdexd kdexd force-pushed the test-util branch 14 times, most recently from 09adfcc to 71bc70d Compare March 5, 2016 17:11
karandesai-96 added 3 commits March 6, 2016 11:15
- Indentation was kept 3x spaces, increased to 4x.

- Parameter 'input' shadowed built-in name input, so rename
  it to 'int_input'.

- Adds param and returns description in docstring, makes the
  doctests shorter and more precise.

- Replaces deprecated style of raising exceptions.

- Removes C-style for-in range looping to a better and more
  pythonic style 'enumerate'.
- numpy, scipy, pandas and matplotlib versions were
  increased in conda-requirements.
- astropy==1.0.4 and numpy==1.10.0 cannot work
  together. numpy==1.10.0 is required to solve
  libgfortran issue, so astropy is changed from
  1.0.4 to 1.0.5

- Same case for pytables==3.2 hence is changed
  to 3.2.2
@kdexd kdexd force-pushed the test-util branch 2 times, most recently from f10d13e to eda1bbf Compare March 7, 2016 02:36
- Adds testcase for raising MalformedElementSymbolError
  in element_symbol2atomic_number.

- Combines tests for test_parse_quantity into one test,
  and adds testcases for raising MalformedQuantityError.
- Coverage for various exceptions raised by the
  species_string_to_tuple method. Similarly for
  species_tuple_to_string method.
@kdexd
Copy link
Author

kdexd commented Mar 7, 2016

  • Many tests did not check whether a method raises exceptions as defined or not, so the test_methods were improved by adding test cases and using pytest.raises to increase coverage by checking Exceptions raised properly.
  • These methods are : test_element_symbol2atomic_number, test_parse_quantity,species_string_to_tuple, species_tuple_to_string.
  • The coverage of tardis/util.py has reached so far till around 65%.
  • The code in tardis/tests/test_util.py is cluttered up a bit. One next commit has just cosmetic changes, just to make subsequent work easier:
    • Uniform code style
    • PEP8 fixes
    • Rearrangement of test_methods in same order as tardis/util.py

karandesai-96 added 3 commits March 7, 2016 11:37
- Rearranged tests in same order as they are
  in 'tardis/util.py'.

- Fixed pep8 violations and the testcases in
  pytest decorators were reorganized as one
  per line for better readability.
- Indentation was kept 3x, increased to 4x.

- Parameters 'input and 'sum' shadowed built-in
  names, so changed them to 'roman_input' and
  'result'.

- Adds 'param' and 'returns' description in the
  docstring.

- Replaces deprecated style of raising exceptions.
(10 , 'X'), (9 , 'IX'), (5 , 'V'), (4 , 'IV'), (1, 'I')]

result = ''
for iterable, int_roman_tuple in enumerate(int_roman_tuples):
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need enumerate here. There must be a way to iterate and get int and str directly from the loop.

for int, str in int_roman_tuples:

Something like that but working(haven't tested only guessed that it won't that easily).

Copy link
Author

Choose a reason for hiding this comment

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

Okay, I am working upon it.

@kdexd
Copy link
Author

kdexd commented May 20, 2016

@wkerzendorf @unoebauer @yeganer Is this relevant or should I close ? (Made before applying to demonstrate coding capability).

@unoebauer
Copy link
Contributor

As far as I see it, parts of the ulit.py are no longer used or relevant. We should go over it at some point and figure out which of the tools therein are still relevant and which not. Afterwards, we can then worry about unit tests for those. For now I wouldn't worry about it. But let's leave the PR open so we don't forget :)

@wkerzendorf wkerzendorf merged commit 2e858b8 into tardis-sn:master Nov 11, 2016
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.

4 participants