morganjwilliams / pyrolite

A set of tools for getting the most from your geochemical data.
https://pyrolite.readthedocs.io
Other
132 stars 36 forks source link

[FEATURE] close and normalise functions in pyrolite.comp.codata #103

Open sarahshi opened 5 months ago

sarahshi commented 5 months ago

Hi Morgan! I am working on some codata functions and thought I'd provide a very small patch for a note in the close function. I added a UserWarning for when negative values are in either the array for close or in the dataframe for normalise.

Is your feature request related to a problem? Please describe. This feature request addresses a comment in the documentation for pyrolite.comp.codata

Describe the solution you'd like Provide warnings when negative values are found in the close and normalise functions, explicitly replace zeros in division with NaN

Describe alternatives you've considered Solution provided in commit 267de50

morganjwilliams commented 4 months ago

Hey @sarahshi! Apologies, I've been on a long block of leave. Thanks for adding an issue, this will be a nice little quality of life addition. Happy for you to open a PR onto to develop, otherwise I can just replicate the commit. l take a look now, and send through any comments.

sarahshi commented 4 months ago

Hi @morganjwilliams. No worries at all! I incorporated your suggested logic, made small modifications to codata.py to have the renormalise function replace negative values with np.nan, and altered the UserWarning accordingly. See commit 58329ee for the new updates. I will open a pull request onto the develop branch now. Please let me know if you have any further suggested modifications to the code.