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

Apex class update #76

Merged
merged 13 commits into from Apr 29, 2021
Merged

Apex class update #76

merged 13 commits into from Apr 29, 2021

Conversation

aburrell
Copy link
Owner

Description

Updated Apex class by:

  • adding __repr__, __str__, and __eq__ magic methods
  • adding a latitude check to the get_babs method
  • organizing Apex methods by type (magic, hidden, user-facing)
  • reducing complexity of methods

Added unit tests for the new methods and input tests. This PR fixes #71 .

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Added unit tests and ran locally. Also:

import apexpy
apex_out = apexpy.Apex(date=2015, refh=300.0)
print(apex_out)

Yields:

Apex class conversions performed with
-------------------------------------
Decimal Year: 2015.00000000
Reference height: 300.000 km
Earth radius: 6371.009 km

Coefficient file: '/Users/aburrell/Programs/Git/apexpy/src/apexpy/apexsh.dat'
Cython Fortran library: '/Users/aburrell/Programs/Git/apexpy/src/apexpy/fortranapex.cpython-37m-darwin.so'

Then:

new_apex = eval(apex_out.__repr__())
new_apex == apex_out

Yields True. Continuing:

new_apex.set_refh(600.0)
new_apex == apex_out

Yields False.

Test Configuration:

  • Operating system: OS X Mojave
  • Python version number: 3.7
  • Compiler with version number: gcc version 9.3.0 (MacPorts gcc9 9.3.0_5)
  • Any details about your local setup that are relevant: branched from develop

Checklist:

  • Make sure you are merging into the develop (not main) branch
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • Add a note to Changelog.rst, summarising the changes
  • Add yourself to AUTHORS.rst and .zenodo.json

Added standard magic class methods `__repr__`, `__str__`, and `__eq__` to improve class interactions.  Also updated docstrings, updated inline comments, added some missing docstrings, improved variable names, and simplified the logic block in the convert method.
Updated the apex class by:
- organizing methods by type (magic, hidden, user-facing),
- adding missing docstrings,
- adding block comments,
- improving descriptive variable names,
- reducing duplicate code lines, and
- adding a latitude check for the `get_babs` hidden method.
Fixed type of `returnvals` to support in-place operations.
Fixed bug introduced when reducing duplicate code lines in general hidden mapping method.
Updated the invalid transformation unit test to look for the updated error type and message.
Updated the capitalization in the `Apex.__str__` method output.
Added unit tests for Apex class including:
- `__str__` method,
- `__repr__` method,
- `__eq__` method,
- bad latitude ValueError in `get_babs`, and
- bad flag in `_map_EV_to_height`.
Fixed bugs in `Apex.__eq__` to make sure all attributes are evaluated and get the comparison attributes from the comparison object.
Updated changelog, adding a summary of this PR's changes.
@aburrell aburrell linked an issue Apr 28, 2021 that may be closed by this pull request
Deepcopy isn't working in python 3.6, but you can do the same thing with eval.
Improved equality method by allowing equality if both objects are missing tested attributes.  Also added more block comments.
Added more tests for apex class equality comparisons and fixed bug where two unit tests had the same name.
Removed a print statement used for debugging.
@aburrell aburrell added this to the 1.1.1 Release milestone Apr 28, 2021
@aburrell aburrell merged commit 7b256e9 into develop Apr 29, 2021
@aburrell aburrell deleted the apex_class_update branch April 29, 2021 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: get_babs has no latitude limit
1 participant