From 37a20e49e776c6d9eda27a4a597587ae56548cf1 Mon Sep 17 00:00:00 2001 From: WEgeophysics Date: Sat, 9 Mar 2024 19:55:42 +0800 Subject: [PATCH 1/2] fix bug in frequency check --- docs/_static/switcher.json | 9 +++++-- docs/conf.py | 15 +++++++++--- docs/whatsnew/index.rst | 1 + docs/whatsnew/v0.3.2.rst | 18 ++++++++++++++ watex/methods/em.py | 49 +++++++++++++++++++++----------------- 5 files changed, 65 insertions(+), 27 deletions(-) create mode 100644 docs/whatsnew/v0.3.2.rst diff --git a/docs/_static/switcher.json b/docs/_static/switcher.json index 8d089cd..9d71296 100644 --- a/docs/_static/switcher.json +++ b/docs/_static/switcher.json @@ -1,11 +1,16 @@ [ { "name": "dev", - "version": "v0.3.2", + "version": "v0.3.3", "url": "https://watex.readthedocs.io/en/latest/" }, + { + "name": "0.3.2 (stable)", + "version": "v0.3.1", + "url": "https://watex.readthedocs.io/en/0.3.2/" + }, { - "name": "0.3.1 (stable)", + "name": "0.3.1", "version": "v0.3.1", "url": "https://watex.readthedocs.io/en/0.3.1/" }, diff --git a/docs/conf.py b/docs/conf.py index 058301a..794d49a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -144,8 +144,6 @@ html_static_path = ['_static', 'example_thumbs'] html_css_files = ["css/custom.css"] #?v={watex.__version__} query removed. - - # todo_include_todos = True html_logo = "_static/logo.svg" html_favicon = "_static/favicon.ico" @@ -153,8 +151,19 @@ # Define the json_url for our version switcher. json_url = "https://watex.readthedocs.io/en/latest/_static/switcher.json" +# Define the json_url for our version switcher. +json_url = "https://watex.readthedocs.io/en/latest/_static/switcher.json" + +# Define the version we use for matching in the version switcher. +# Here we need to ensure that the version_match corresponds to our stable version +version_match = f"v{watex.__version__}" #"v0.3.1" # This should match the version key in your switcher.json for the stable version + +# Use this if you want to set the switcher version from the environment or +# default to the provided stable version +# version_match = os.environ.get("READTHEDOCS_VERSION", "v0.3.1") + # Define the version we use for matching in the version switcher. -version_match = os.environ.get("READTHEDOCS_VERSION", f"v{watex.__version__}") +#version_match = os.environ.get("READTHEDOCS_VERSION", f"v{watex.__version__}") # If READTHEDOCS_VERSION doesn't exist, we're not on RTD # If it is an integer, we're in a PR build and the version isn't correct. diff --git a/docs/whatsnew/index.rst b/docs/whatsnew/index.rst index 3c0817c..3966724 100644 --- a/docs/whatsnew/index.rst +++ b/docs/whatsnew/index.rst @@ -13,6 +13,7 @@ Version 0.3 .. toctree:: :maxdepth: 2 + v0.3.2 v0.3.1 v0.3.0 diff --git a/docs/whatsnew/v0.3.2.rst b/docs/whatsnew/v0.3.2.rst new file mode 100644 index 0000000..d73a997 --- /dev/null +++ b/docs/whatsnew/v0.3.2.rst @@ -0,0 +1,18 @@ +v0.3.2 (March 9, 2024) +----------------------- + +Minor changes have been made to the API since version ``v0.3.1``, leading +to fixed bugs in frequencies handling. + +- |Fix| Fixed the bound error in :meth:`~watex.methods.MT.remove_static_shift` by + rounding the frequency checks to 5 decimal places. + +- |Fix| There is no longer a need to recompute frequencies when no extraneous + frequencies are detected for omission. :meth:`~watex.methods.MT.drop_frequencies` + now consistently returns the original :term:`MT` object. + + + + + + diff --git a/watex/methods/em.py b/watex/methods/em.py index 5a56f31..2611d26 100644 --- a/watex/methods/em.py +++ b/watex/methods/em.py @@ -4277,7 +4277,6 @@ def _update_z (z_or_edis, /, ufunc , args =(), **kws ): return new_zObjs - def drop_frequencies ( ediObjs: List[EDIO] | os.PathLike, /, tol:float ="auto", @@ -4370,7 +4369,7 @@ def drop_frequencies ( raise EMError ( "tolerance parameter or frequency values to discard" " could not be None. Consider ``tol='auto'``to" - " automatically control 50% quality of the data." + " automatically control 50% quality of the data." ) if str(tol).lower() == 'auto': @@ -4400,29 +4399,35 @@ def drop_frequencies ( # for consistency freqs = np.sort (freqs )[::-1 ] - if len(freqs)==0 and verbose: - print(f"Noise frequencies for {tol*100}% tolerance" - " have not been detected.") - else: listing_items_format(freqs ,begintext= "Frequencies" , + if len(freqs)==0: + if verbose: + print(f"Noise frequencies for {tol*100}% tolerance" + " have not been detected.") + # return object and frequency list + freqslist = [ edio.Z._freq for edio in ediObjs ] + Zobj = [ edio.Z for edio in ediObjs ] + + else: + listing_items_format(freqs ,begintext= "Frequencies" , endtext="Hz have been dropped.", inline =True , verbose =verbose ) - # use mask to set a new collection of Z - Zobj = []; freqslist=[] - for kk , edio in enumerate (ediObjs ): - mask = np.isin ( edio.Z._freq, freqs) - # mask = np.ones ( len( edio.Z._freq), dtype = bool ) - # mask [ u_freqs] = False - z_new = edio.Z._z [~mask , :, :] - # similar to np.delete (edio.Z._z , u_freqs, axis =0 ) - z_err_new = edio.Z._z_err [~mask , :, :] - new_freq = edio.Z._freq[ ~mask ] - - Z =EMz ( - z_array= z_new , z_err_array= z_err_new , freq = new_freq - ) - Zobj.append(Z ) - freqslist.append (new_freq) + # use mask to set a new collection of Z + Zobj = []; freqslist=[] + for kk , edio in enumerate (ediObjs ): + mask = np.isin ( edio.Z._freq, freqs) + # mask = np.ones ( len( edio.Z._freq), dtype = bool ) + # mask [ u_freqs] = False + z_new = edio.Z._z [~mask , :, :] + # similar to np.delete (edio.Z._z , u_freqs, axis =0 ) + z_err_new = edio.Z._z_err [~mask , :, :] + new_freq = edio.Z._freq[ ~mask ] + + Z =EMz ( + z_array= z_new , z_err_array= z_err_new , freq = new_freq + ) + Zobj.append(Z ) + freqslist.append (new_freq) if get_max_freqs: freqslist = freqslist [ From 99e2a9608127b583b3a7fd244b25090feccb7b51 Mon Sep 17 00:00:00 2001 From: WEgeophysics Date: Sat, 9 Mar 2024 20:00:30 +0800 Subject: [PATCH 2/2] fix bug in frequency check --- pyproject.toml | 2 +- setup.py | 2 +- watex/__init__.py | 2 +- watex/_version.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d9a881c..10180c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "watex" -version = "0.3.1" +version = "0.3.2" description = "Machine learning research in water exploration" readme = "README.md" authors = [{name = "Laurent Kouadio", email = "etanoyau@gmail.com"}] diff --git a/setup.py b/setup.py index b96e3cf..9fd50e7 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ try: import watex VERSION = watex.__version__ -except: VERSION ='0.3.1' +except: VERSION ='0.3.2' # set global variables DISTNAME = "watex" DESCRIPTION= "Machine learning research in water exploration" diff --git a/watex/__init__.py b/watex/__init__.py index fad9fd2..d310163 100644 --- a/watex/__init__.py +++ b/watex/__init__.py @@ -35,7 +35,7 @@ from . import _version __version__ = _version.version.split('.dev')[0] except ImportError: - __version__ = "0.3.1" + __version__ = "0.3.2" # # set loging Level logging.getLogger(__name__)#.setLevel(logging.WARNING) diff --git a/watex/_version.py b/watex/_version.py index 747927e..1c0fd8c 100644 --- a/watex/_version.py +++ b/watex/_version.py @@ -1,4 +1,4 @@ # file generated by setuptools_scm # don't change, don't track in version control -__version__ = version = '0.3.1.dev1+g10707dc.d20230709' +__version__ = version = '0.3.2.dev1+g10707dc.d20230709' __version_tuple__ = version_tuple = (0, 3, 2, 'dev1', 'g10707dc.d20230709')