MHKiT-Software / MHKiT-Python

MHKiT-Python provides the marine renewable energy (MRE) community tools for data processing, visualization, quality control, resource assessment, and device performance.
https://mhkit-software.github.io/MHKiT/
BSD 3-Clause "New" or "Revised" License
47 stars 45 forks source link

Lint Loads #288

Closed ssolson closed 3 months ago

ssolson commented 4 months ago

This PR is part of an ongoing effort to enhance the MHKiT codebase's quality and maintainability, specifically targeting the loads module. Our main objectives were to ensure Pylint compliance and to enrich the code with type hints across all functions within this module. Here's a summary of the key changes and considerations:

Pylint Compliance

Revised the loads module to adhere to Pylint's coding standards. This involved a comprehensive review and subsequent adjustments to formatting, naming conventions, and structure to meet the stringent requirements set forth by Pylint.

A new Pylint test can be seen on this PR that enforces Pylint compliance on just the loads module.

Type Hints Addition

Type hints have been added to each function within the module, providing clearer documentation and facilitating better IDE support for type checking. This enhancement is expected to improve code readability and maintainability significantly.

Exceptions & Disables

While striving for Pylint compliance, we've encountered a few instances where adhering strictly to Pylint's recommendations would either compromise the codebase's integrity or cause excessive delays. In these cases, we've opted to disable specific Pylint checks, detailed as follows:

ssolson commented 4 months ago

@akeeste this should be ready for a review. I pushed really hard to get this finished before being OOO next week. I hope I didn't miss anything but I believe I have all my bases covered for a review.

akeeste commented 3 months ago

sorry for the wait here, I finally got #285 ironed out and ready to go. I blocked time to review this PR first thing next week.

ssolson commented 3 months ago

thanks for this PR @ssolson. Overall I think these pylint changes look pretty good, though it's hard to review the loads.extreme since it was broken into multiple files. Is there any specific changes to review for those functions?

I think your to_numeric_array function is actually a good complement to the utils.data_utils functions that convert function input to xarray format. There is some overlap, but I also see use cases for both right now--especially in graphics functions that require a more simplified numeric format, or function like those in loads.extreme.extremes that were previously built to only take numpy arrays.

Adam thanks for the review. I don't have anything specific to check. I was required to breakout the functions into multiple files because the file was over 1000 lines long which throws a pylint error.

akeeste commented 3 months ago

@ssolson That makes sense. I'll assume that any other line changes were similar to those done in other loads submodules. Since the tests are passing, I'm assuming all those changes are okay.

The only outstanding thing here is to decide if we can consolidate type handling functions. Let me know what you think after reviewing #285. I support merging both this and #285, then updating/standardizing type handling in the loads module in a new small PR.

ssolson commented 3 months ago

@ssolson That makes sense. I'll assume that any other line changes were similar to those done in other loads submodules. Since the tests are passing, I'm assuming all those changes are okay.

The only outstanding thing here is to decide if we can consolidate type handling functions. Let me know what you think after reviewing #285. I support merging both this and #285, then updating/standardizing type handling in the loads module in a new small PR.

@akeeste I think there are a couple of things to address on #285 so lets get this PR merged into develop and I think you should move your 2 util functions into type_handling vs the current data_utils as discussed in my review.

akeeste commented 3 months ago

@ssolson agreed, type_handling is a better name. Merging!