From 048d2311623ecc903856fd188a57e82be1086ce7 Mon Sep 17 00:00:00 2001 From: jdpye Date: Thu, 8 Dec 2022 13:41:30 -0400 Subject: [PATCH 1/7] add match_taxa wrap, fix env.yml --- environment.yml | 1 + pyobistools/taxa.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/environment.yml b/environment.yml index a97ff9b..5b3f866 100644 --- a/environment.yml +++ b/environment.yml @@ -5,6 +5,7 @@ dependencies: - geopandas - pyworms - ckanapi +- httpx - plotly - async - requests diff --git a/pyobistools/taxa.py b/pyobistools/taxa.py index 6feaceb..d685a47 100644 --- a/pyobistools/taxa.py +++ b/pyobistools/taxa.py @@ -11,6 +11,20 @@ from pyobistools.utils import removesuffix +import validation.check_scientificname_and_ids as check_names + +def match_taxa(names, ask=True, itis_usage=False): + """ + Wrap the existing functionality in validation in the expected name for this function as per R's iobis/obistools. + + @param names List of scientific names to check against + @param ask Do we ask the user to resolve multi-match or ambiguous names? + @param itis_usage Pass through the ITIS check setting for the client function to handle + + @return structure with appended lsids where WoRMS (or ITIS can resolve them) + """ + return check_names.check_scientificname_and_ids(names, value='names', itis_usage=itis_usage) + STANDARD_SPECIES_COLUMNS = { 'taxon_id': np.nan, 'url': '', From 82cf154f3b481690635ff93fe4b2357830902741 Mon Sep 17 00:00:00 2001 From: Jon Pye Date: Fri, 24 Nov 2023 14:35:34 -0400 Subject: [PATCH 2/7] Update .pre-commit-config.yaml fix flake8 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 29e11e4..5220f16 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,6 +14,6 @@ repos: exclude: ^src/ - repo: https://github.com/pycqa/flake8 - rev: 3.9.2 + rev: 6.1.0 hooks: - id: flake8 From 93773102e8595def45c7cb233c82f9eb010f6edd Mon Sep 17 00:00:00 2001 From: Jon Pye Date: Fri, 24 Nov 2023 14:39:04 -0400 Subject: [PATCH 3/7] flake fixes --- pyobistools/taxa.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyobistools/taxa.py b/pyobistools/taxa.py index d685a47..1cd7110 100644 --- a/pyobistools/taxa.py +++ b/pyobistools/taxa.py @@ -14,6 +14,7 @@ import validation.check_scientificname_and_ids as check_names def match_taxa(names, ask=True, itis_usage=False): + """ Wrap the existing functionality in validation in the expected name for this function as per R's iobis/obistools. @@ -23,8 +24,10 @@ def match_taxa(names, ask=True, itis_usage=False): @return structure with appended lsids where WoRMS (or ITIS can resolve them) """ + return check_names.check_scientificname_and_ids(names, value='names', itis_usage=itis_usage) + STANDARD_SPECIES_COLUMNS = { 'taxon_id': np.nan, 'url': '', From 701b06beb6730d971c388c465a055c4cc40998d7 Mon Sep 17 00:00:00 2001 From: Jon Pye Date: Fri, 24 Nov 2023 14:42:15 -0400 Subject: [PATCH 4/7] flake8 fixes again --- pyobistools/taxa.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyobistools/taxa.py b/pyobistools/taxa.py index 1cd7110..39efdb0 100644 --- a/pyobistools/taxa.py +++ b/pyobistools/taxa.py @@ -13,8 +13,8 @@ import validation.check_scientificname_and_ids as check_names -def match_taxa(names, ask=True, itis_usage=False): +def match_taxa(names, ask=True, itis_usage=False): """ Wrap the existing functionality in validation in the expected name for this function as per R's iobis/obistools. From b8948bb92aa03a7cf2d824d54d0ef5472a99d831 Mon Sep 17 00:00:00 2001 From: Jon Pye Date: Fri, 24 Nov 2023 14:47:35 -0400 Subject: [PATCH 5/7] not sure what flake wants anymore --- pyobistools/taxa.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pyobistools/taxa.py b/pyobistools/taxa.py index 39efdb0..d8726f2 100644 --- a/pyobistools/taxa.py +++ b/pyobistools/taxa.py @@ -14,20 +14,6 @@ import validation.check_scientificname_and_ids as check_names -def match_taxa(names, ask=True, itis_usage=False): - """ - Wrap the existing functionality in validation in the expected name for this function as per R's iobis/obistools. - - @param names List of scientific names to check against - @param ask Do we ask the user to resolve multi-match or ambiguous names? - @param itis_usage Pass through the ITIS check setting for the client function to handle - - @return structure with appended lsids where WoRMS (or ITIS can resolve them) - """ - - return check_names.check_scientificname_and_ids(names, value='names', itis_usage=itis_usage) - - STANDARD_SPECIES_COLUMNS = { 'taxon_id': np.nan, 'url': '', @@ -111,6 +97,20 @@ def add_suffix(name: str) -> t.List[str]: return [name.strip() + s for s in suffixes] +def match_taxa(names, ask=True, itis_usage=False): + """ + Wrap the existing functionality in validation in the expected name for this function as per R's iobis/obistools. + + @param names List of scientific names to check against + @param ask Do we ask the user to resolve multi-match or ambiguous names? + @param itis_usage Pass through the ITIS check setting for the client function to handle + + @return structure with appended lsids where WoRMS (or ITIS can resolve them) + """ + + return check_names.check_scientificname_and_ids(names, value='names', itis_usage=itis_usage) + + def search_worms(names: t.List[str], kwargs: t.Dict[str, t.Any] = {}) -> pd.DataFrame: """ From b78efe7dc637beeaf2c3e8b8cff8e017928a55cf Mon Sep 17 00:00:00 2001 From: Jon Pye Date: Fri, 24 Nov 2023 14:48:56 -0400 Subject: [PATCH 6/7] flake why --- pyobistools/taxa.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyobistools/taxa.py b/pyobistools/taxa.py index d8726f2..85ee451 100644 --- a/pyobistools/taxa.py +++ b/pyobistools/taxa.py @@ -98,7 +98,7 @@ def add_suffix(name: str) -> t.List[str]: def match_taxa(names, ask=True, itis_usage=False): - """ + """ Wrap the existing functionality in validation in the expected name for this function as per R's iobis/obistools. @param names List of scientific names to check against From f1c20ecf12b0a15524c30b74f5e18a2213f4609d Mon Sep 17 00:00:00 2001 From: Jon Pye Date: Fri, 24 Nov 2023 14:51:45 -0400 Subject: [PATCH 7/7] change reference to validation module --- pyobistools/taxa.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyobistools/taxa.py b/pyobistools/taxa.py index 85ee451..62c33e3 100644 --- a/pyobistools/taxa.py +++ b/pyobistools/taxa.py @@ -11,7 +11,7 @@ from pyobistools.utils import removesuffix -import validation.check_scientificname_and_ids as check_names +from pyobistools.validation import check_scientificname_and_ids as check_names STANDARD_SPECIES_COLUMNS = {