Skip to content

Conversation

@ssolson
Copy link
Contributor

@ssolson ssolson commented Mar 10, 2025

This PR enforces automatic linting on the tidal module and adds type hints to improve readability and maintainability.

Key Updates:

  • Code Cleanup & Linting: Organized imports, followed PEP 8 conventions, and cleaned up unnecessary comments.
  • Type Hints: Added type hints to all functions for better static analysis and clarity.
  • Variable Naming: Standardized names to follow snake_case for consistency.

ssolson and others added 8 commits December 11, 2024 08:22
This PR updates our git workflow to use `main` as the MHKiT default
branch :
- Many modern projects use `main` as the default branch, aligning with
the GitHub recommendation and broader conventions.
- There is some non-linear history in the previous rebase causing issues
between `develop` & `master`
- `main` was created from the current `develop` branch creating a 1-to-1
liner history between `develop` and the new `main` branch
@ssolson ssolson self-assigned this Mar 12, 2025
@ssolson ssolson added loads module Clean Up Improve code consistency and readability labels Mar 12, 2025
@ssolson ssolson marked this pull request as ready for review March 19, 2025 01:12
@ssolson
Copy link
Contributor Author

ssolson commented Apr 1, 2025

@akeeste could you review this PR?

Copy link
Contributor

@akeeste akeeste left a comment

Choose a reason for hiding this comment

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

Thanks @ssolson, looks great! Take a look at the suggestions:

  • pulling in a couple of the descriptions from our docs when they were informative
  • removing functions from the module-level docstrings.

On module-level docstrings--the autosummary tool allows us to automatically populate the function doc strings within a module without duplicating them, so I'd defer to that. Generally though the module level docstrings are a nice improvement. Once we're through a chunk of linting we can make a docs PR to reference this new content and reduce duplication outside of the source

Comment on lines 16 to 28
Functions:
----------
request_noaa_data(station, parameter, start_date, end_date, proxy=None,
write_json=None):
Loads NOAA current data from the API into a pandas DataFrame,
with optional support for proxy settings and writing data to a JSON
file.
request_noaa_data(station, parameter, start_date, end_date, options=None):
Fetches NOAA data from the API, converts it into a pandas DataFrame (or xarray Dataset),
and caches the result. Supports proxy settings and JSON file export.
_xml_to_dataframe(response):
Converts NOAA response data in XML format into a pandas DataFrame
and returns metadata.
Converts NOAA response data from XML format into a pandas DataFrame and extracts metadata.
read_noaa_json(filename):
Reads a JSON file containing NOAA data saved from the request_noaa_data
function and returns a DataFrame with timeseries site data and metadata.
read_noaa_json(filename, to_pandas=True):
Reads a previously saved JSON file containing NOAA data and returns a pandas DataFrame
(or xarray Dataset) with time-series data and metadata.
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove in favor of the docs "autosummary" feature https://mhkit-software.github.io/MHKiT/mhkit-python/api.tidal.html#io. This will also prevent duplicate descriptions to upkeep

Suggested change
Functions:
----------
request_noaa_data(station, parameter, start_date, end_date, proxy=None,
write_json=None):
Loads NOAA current data from the API into a pandas DataFrame,
with optional support for proxy settings and writing data to a JSON
file.
request_noaa_data(station, parameter, start_date, end_date, options=None):
Fetches NOAA data from the API, converts it into a pandas DataFrame (or xarray Dataset),
and caches the result. Supports proxy settings and JSON file export.
_xml_to_dataframe(response):
Converts NOAA response data in XML format into a pandas DataFrame
and returns metadata.
Converts NOAA response data from XML format into a pandas DataFrame and extracts metadata.
read_noaa_json(filename):
Reads a JSON file containing NOAA data saved from the request_noaa_data
function and returns a DataFrame with timeseries site data and metadata.
read_noaa_json(filename, to_pandas=True):
Reads a previously saved JSON file containing NOAA data and returns a pandas DataFrame
(or xarray Dataset) with time-series data and metadata.

metadata : dict or None
Request metadata. If returning xarray, metadata is instead attached to
the data's attributes.
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

git compares the changes in request_noaa_data poorly, but I'm more or less following how things are broken up into multiple functions

@ssolson ssolson merged commit f6f7301 into MHKiT-Software:develop Apr 8, 2025
43 checks passed
@ssolson ssolson mentioned this pull request Apr 9, 2025
@ssolson ssolson deleted the lint-cec branch May 20, 2025 14:24
akeeste pushed a commit to akeeste/MHKiT-Python that referenced this pull request Sep 30, 2025
- Enforce PyLint and add type hints
@akeeste akeeste mentioned this pull request Sep 30, 2025
akeeste added a commit that referenced this pull request Sep 30, 2025
v1.0.0
# MHKiT v1.0.0
## New Features
* Sound Exposure Level by @jmcvey3 in #388
* Add discharge function to MHKiT by @jmcvey3 in #385

## Functionality enhancements
* Fix for corrupted Nortek files by @jmcvey3 in #372
* Update integral length scale function by @jmcvey3 in #376
* Fix ever-changing RDI RiverPro depth bin ranges by @jmcvey3 in #378
* Allow clean functions to handle _avg variables by @jmcvey3 in #377
* IEC TS 62600 updates by @akeeste in #382
* MLER explanation updates/corrections by @rgcoe in #393
* Improve Nortek2 index file creator functions by @jmcvey3 in #397
* Read Sentinel V specific data packets by @jmcvey3 in #396
* Short list of VMDAS updates by @jmcvey3 in #405
* Allow user to specify universal Kolmogorov constant for TKE dissipation rate function by @jmcvey3 in #406
* Nortek Dual Profile Dataset Rotation by @jmcvey3 in #414

## Source code improvements
* Lint Tidal by @ssolson in #386
* Lint river module by @ssolson in #389
* Lint hindcast by @ssolson in #398
* Modernize Package Configuration by @ssolson in #400
* Configure specific warnings by @ssolson in #401

## Bug fixes
* Avoid failing to scan very large files by @jmcvey3 in #371
* Acoustics SPL bugfix by @jmcvey3 in #379
* DOLfYN/RDI: Set  `fs` to NaN when typical calculation methods yield error (#408) by @simmsa in #409

## Testing and Continuous Integration Updates
* Fix Jupyter Notebook tests running Python 3.13 by @ssolson in #380
* CI Test Clean Up: Mock USGS, Acoustic Tolerances by @ssolson in #404
* Speed up tests with concurrency checks to prevent duplicate workflows on PRs from develop into main or from main into develop by @akeeste
* Define MPLBACKEND to decrease intermittent matplotlib errors in tests by @akeeste

## Documentation and Examples
* Add WEC-Sim power performance example  by @akeeste in #395
* Update dolfyn function docstrings and associated notebooks by @jmcvey3 in #412
* Update examples by @akeeste in #417
* Update installation instructions in README.md by @akeeste
* Adjust acoustics test tolerances by @akeeste in #420

**Full Changelog**: v0.9.0...v1.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Clean Up Improve code consistency and readability loads module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants