From ce08217b74363e58e7abd03f7ddea7670e566a1e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 11:26:41 +0000 Subject: [PATCH 01/16] Bump spec_tests/hed-examples from `5e9f9eb` to `5c3544a` Bumps [spec_tests/hed-examples](https://github.com/hed-standard/hed-examples) from `5e9f9eb` to `5c3544a`. - [Release notes](https://github.com/hed-standard/hed-examples/releases) - [Commits](https://github.com/hed-standard/hed-examples/compare/5e9f9eba404e0b23f0818f5adf1056fbdf60269c...5c3544a985b509c15fbae70212fe05d92bb5f697) --- updated-dependencies: - dependency-name: spec_tests/hed-examples dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- spec_tests/hed-examples | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec_tests/hed-examples b/spec_tests/hed-examples index 5e9f9eba..5c3544a9 160000 --- a/spec_tests/hed-examples +++ b/spec_tests/hed-examples @@ -1 +1 @@ -Subproject commit 5e9f9eba404e0b23f0818f5adf1056fbdf60269c +Subproject commit 5c3544a985b509c15fbae70212fe05d92bb5f697 From bb3c8ba6007d916c2517ab9359a193dbc55bf7e5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 11:43:39 +0000 Subject: [PATCH 02/16] Bump paambaati/codeclimate-action from 6.0.0 to 8.0.0 Bumps [paambaati/codeclimate-action](https://github.com/paambaati/codeclimate-action) from 6.0.0 to 8.0.0. - [Release notes](https://github.com/paambaati/codeclimate-action/releases) - [Changelog](https://github.com/paambaati/codeclimate-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/paambaati/codeclimate-action/compare/v6.0.0...v8.0.0) --- updated-dependencies: - dependency-name: paambaati/codeclimate-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5654b31d..bed2e1c9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -133,7 +133,7 @@ jobs: with: coverageCommand: coverage xml debug: true - uses: paambaati/codeclimate-action@v6.0.0 + uses: paambaati/codeclimate-action@v8.0.0 env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} From cdec86df403cab19decc7013b6d392c6802036eb Mon Sep 17 00:00:00 2001 From: IanCa Date: Mon, 17 Jun 2024 18:11:16 -0500 Subject: [PATCH 03/16] Add a search util function to convert to long --- hed/models/basic_search_util.py | 38 ++++++++++++++++++++++++++ tests/models/test_basic_search_util.py | 20 ++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 hed/models/basic_search_util.py create mode 100644 tests/models/test_basic_search_util.py diff --git a/hed/models/basic_search_util.py b/hed/models/basic_search_util.py new file mode 100644 index 00000000..8029094f --- /dev/null +++ b/hed/models/basic_search_util.py @@ -0,0 +1,38 @@ +""" +Utilities to support HED searches based on strings. +""" +from hed.models.hed_string import HedString +from hed.models.hed_tag import HedTag + + +def convert_query_to_form(search_query, schema): + """Converts the given basic search query into a hed_string + + Parameters: + search_query(str): The basic search query to convert. + schema(HedSchema): The schema to use to convert tags + + Returns: + long_query(str): The converted search query, in long form. + """ + input_tags = HedString.split_hed_string(search_query) + output_string = "" + skippable_prefix = ("@", "~") + skippable_suffix = ("*", ) + for is_hed_tag, (startpos, endpos) in input_tags: + input_tag = search_query[startpos:endpos] + add_suffix = "" + if is_hed_tag: + if input_tag.startswith(skippable_prefix): + output_string += input_tag[:1] + input_tag = input_tag[1:] + + if input_tag.endswith(skippable_suffix): + add_suffix = input_tag[-1:] + input_tag = input_tag[:-1] + output_string += HedTag(input_tag, schema).long_tag + output_string += add_suffix + else: + output_string += input_tag + + return output_string diff --git a/tests/models/test_basic_search_util.py b/tests/models/test_basic_search_util.py new file mode 100644 index 00000000..91574f4c --- /dev/null +++ b/tests/models/test_basic_search_util.py @@ -0,0 +1,20 @@ +import unittest +from hed import load_schema_version +from hed.models.basic_search_util import convert_query_to_form + + +class TestConvertQueryToForm(unittest.TestCase): + schema = load_schema_version("8.3.0") + + def test_basic_convert(self): + input = "@Event, Head-part*, Time-interval/1" + expected_output = "@Event, Item/Biological-item/Anatomical-item/Body-part/Head-part*, Property/Data-property/Data-value/Spatiotemporal-value/Temporal-value/Time-interval/1" + + actual_output = convert_query_to_form(input, self.schema) + self.assertEqual(expected_output, actual_output) + + input = "@Head-part*, Event, Time-interval/1" + expected_output = "@Item/Biological-item/Anatomical-item/Body-part/Head-part*, Event, Property/Data-property/Data-value/Spatiotemporal-value/Temporal-value/Time-interval/1" + + actual_output = convert_query_to_form(input, self.schema) + self.assertEqual(expected_output, actual_output) \ No newline at end of file From 4d940712d3df7fd208037181098a409d34319ed4 Mon Sep 17 00:00:00 2001 From: IanCa Date: Mon, 17 Jun 2024 18:12:48 -0500 Subject: [PATCH 04/16] Rename convert_query --- hed/models/basic_search_util.py | 2 +- tests/models/test_basic_search_util.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hed/models/basic_search_util.py b/hed/models/basic_search_util.py index 8029094f..7e3224a5 100644 --- a/hed/models/basic_search_util.py +++ b/hed/models/basic_search_util.py @@ -5,7 +5,7 @@ from hed.models.hed_tag import HedTag -def convert_query_to_form(search_query, schema): +def convert_query(search_query, schema): """Converts the given basic search query into a hed_string Parameters: diff --git a/tests/models/test_basic_search_util.py b/tests/models/test_basic_search_util.py index 91574f4c..9701ca65 100644 --- a/tests/models/test_basic_search_util.py +++ b/tests/models/test_basic_search_util.py @@ -1,6 +1,6 @@ import unittest from hed import load_schema_version -from hed.models.basic_search_util import convert_query_to_form +from hed.models.basic_search_util import convert_query class TestConvertQueryToForm(unittest.TestCase): @@ -10,11 +10,11 @@ def test_basic_convert(self): input = "@Event, Head-part*, Time-interval/1" expected_output = "@Event, Item/Biological-item/Anatomical-item/Body-part/Head-part*, Property/Data-property/Data-value/Spatiotemporal-value/Temporal-value/Time-interval/1" - actual_output = convert_query_to_form(input, self.schema) + actual_output = convert_query(input, self.schema) self.assertEqual(expected_output, actual_output) input = "@Head-part*, Event, Time-interval/1" expected_output = "@Item/Biological-item/Anatomical-item/Body-part/Head-part*, Event, Property/Data-property/Data-value/Spatiotemporal-value/Temporal-value/Time-interval/1" - actual_output = convert_query_to_form(input, self.schema) + actual_output = convert_query(input, self.schema) self.assertEqual(expected_output, actual_output) \ No newline at end of file From fe17f135cbbadeed1708ad27f0a16e9711e7bbb5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Jun 2024 11:45:58 +0000 Subject: [PATCH 05/16] Bump spec_tests/hed-examples from `5c3544a` to `82a6278` Bumps [spec_tests/hed-examples](https://github.com/hed-standard/hed-examples) from `5c3544a` to `82a6278`. - [Release notes](https://github.com/hed-standard/hed-examples/releases) - [Commits](https://github.com/hed-standard/hed-examples/compare/5c3544a985b509c15fbae70212fe05d92bb5f697...82a627821614752e77b3a12d4d0021c2c6894139) --- updated-dependencies: - dependency-name: spec_tests/hed-examples dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- spec_tests/hed-examples | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec_tests/hed-examples b/spec_tests/hed-examples index 5c3544a9..82a62782 160000 --- a/spec_tests/hed-examples +++ b/spec_tests/hed-examples @@ -1 +1 @@ -Subproject commit 5c3544a985b509c15fbae70212fe05d92bb5f697 +Subproject commit 82a627821614752e77b3a12d4d0021c2c6894139 From d0c330661cf66c82955878293ecbe639e135bcb3 Mon Sep 17 00:00:00 2001 From: IanCa Date: Thu, 20 Jun 2024 18:30:38 -0500 Subject: [PATCH 06/16] Allow unordered df schema loading --- hed/schema/schema_io/df2schema.py | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/hed/schema/schema_io/df2schema.py b/hed/schema/schema_io/df2schema.py index 2fd6e6cc..5b26c19f 100644 --- a/hed/schema/schema_io/df2schema.py +++ b/hed/schema/schema_io/df2schema.py @@ -137,35 +137,19 @@ def _read_schema(self, dataframe): Parameters: dataframe (pd.DataFrame): The dataframe for the main tags section """ - # note: this assumes loading is in order row by row. - # If tags are NOT sorted this won't work.(same as mediawiki) self._schema._initialize_attributes(HedSectionKey.Tags) - known_tag_levels = {"HedTag": -1} - parent_tags = [] + known_parent_tags = {"HedTag": []} level_adj = 0 for row_number, row in dataframe[constants.TAG_KEY].iterrows(): # skip blank rows, though there shouldn't be any if not any(row): continue parent_tag = row[constants.subclass_of] - # Return -1 by default for top level rooted tag support(they might not be in the dict) - raw_level = known_tag_levels.get(parent_tag, -1) + 1 - if raw_level == 0: - parent_tags = [] - level_adj = 0 - else: - level = raw_level + level_adj - if level < len(parent_tags): - parent_tags = parent_tags[:level] - elif level > len(parent_tags): - self._add_fatal_error(row_number, row, - "Invalid level reported from Level column", - HedExceptions.GENERIC_ERROR) - continue - - tag_entry, parent_tags, level_adj = self._add_tag_meta(parent_tags, row_number, row, level_adj) + org_parent_tags = known_parent_tags.get(parent_tag, []).copy() + + tag_entry, parent_tags, _ = self._add_tag_meta(org_parent_tags, row_number, row, level_adj) if tag_entry: - known_tag_levels[tag_entry.short_tag_name] = raw_level + known_parent_tags[tag_entry.short_tag_name] = parent_tags.copy() def _read_section(self, df, section_key): self._schema._initialize_attributes(section_key) From 2f9385c738066fa660be8fcc78dca6f6d2bc3329 Mon Sep 17 00:00:00 2001 From: IanCa Date: Thu, 20 Jun 2024 19:07:24 -0500 Subject: [PATCH 07/16] Delete codepsellrc, add to toml --- .codespellrc | 3 --- pyproject.toml | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 .codespellrc diff --git a/.codespellrc b/.codespellrc deleted file mode 100644 index 18082524..00000000 --- a/.codespellrc +++ /dev/null @@ -1,3 +0,0 @@ -[codespell] -skip = .git,*.pdf,*.svg,deprecated,*.xml,*.mediawiki,*.omn,*.toml -ignore-words-list = covert,hed,assertIn,parms diff --git a/pyproject.toml b/pyproject.toml index b7e341ae..67f8bc46 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -77,5 +77,5 @@ namespaces = false hed = ["schema/schema_data/*.xml", "resources/*.png"] [tool.codespell] -skip = '*.git,*.pdf,*.xml,*.mediawiki,*.svg,versioneer.py,venv*,*.tsv,*.yaml,*.yml,*.json,*.rdf,*.jsonld,spec_tests' +skip = '*.git,*.pdf,*.svg,versioneer.py,venv*,*.tsv,*.yaml,*.yml,*.json,*.rdf,*.jsonld,spec_tests,,*.xml,*.mediawiki,*.omn,*.toml' ignore-words-list = 'te,parms,assertIn' From 972b10cc38b27fc53a6991b17cc844c0bf411b16 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:18:20 +0000 Subject: [PATCH 08/16] Bump spec_tests/hed-specification from `0d8303e` to `0e8a9b1` Bumps [spec_tests/hed-specification](https://github.com/hed-standard/hed-specification) from `0d8303e` to `0e8a9b1`. - [Release notes](https://github.com/hed-standard/hed-specification/releases) - [Commits](https://github.com/hed-standard/hed-specification/compare/0d8303e62193ca71600ff62e85936de335ad5d7f...0e8a9b19308b777d84a33d8d186b380232b2633d) --- updated-dependencies: - dependency-name: spec_tests/hed-specification dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- spec_tests/hed-specification | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec_tests/hed-specification b/spec_tests/hed-specification index 0d8303e6..0e8a9b19 160000 --- a/spec_tests/hed-specification +++ b/spec_tests/hed-specification @@ -1 +1 @@ -Subproject commit 0d8303e62193ca71600ff62e85936de335ad5d7f +Subproject commit 0e8a9b19308b777d84a33d8d186b380232b2633d From 217ec8ec1d8b313e0703e4b27028c17497e09f3c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 11:57:01 +0000 Subject: [PATCH 09/16] Bump spec_tests/hed-specification from `0e8a9b1` to `052bd4a` Bumps [spec_tests/hed-specification](https://github.com/hed-standard/hed-specification) from `0e8a9b1` to `052bd4a`. - [Release notes](https://github.com/hed-standard/hed-specification/releases) - [Commits](https://github.com/hed-standard/hed-specification/compare/0e8a9b19308b777d84a33d8d186b380232b2633d...052bd4aaf39eec8c14425a71665c2264223d8c60) --- updated-dependencies: - dependency-name: spec_tests/hed-specification dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- spec_tests/hed-specification | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec_tests/hed-specification b/spec_tests/hed-specification index 0e8a9b19..052bd4aa 160000 --- a/spec_tests/hed-specification +++ b/spec_tests/hed-specification @@ -1 +1 @@ -Subproject commit 0e8a9b19308b777d84a33d8d186b380232b2633d +Subproject commit 052bd4aaf39eec8c14425a71665c2264223d8c60 From 553ca554d656e75f73a351ae311e94524688ef9a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 11:57:05 +0000 Subject: [PATCH 10/16] Bump spec_tests/hed-examples from `82a6278` to `9e5691f` Bumps [spec_tests/hed-examples](https://github.com/hed-standard/hed-examples) from `82a6278` to `9e5691f`. - [Release notes](https://github.com/hed-standard/hed-examples/releases) - [Commits](https://github.com/hed-standard/hed-examples/compare/82a627821614752e77b3a12d4d0021c2c6894139...9e5691f4ca06cf6ab664fc59f3dfee2ec4b0489e) --- updated-dependencies: - dependency-name: spec_tests/hed-examples dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- spec_tests/hed-examples | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec_tests/hed-examples b/spec_tests/hed-examples index 82a62782..9e5691f4 160000 --- a/spec_tests/hed-examples +++ b/spec_tests/hed-examples @@ -1 +1 @@ -Subproject commit 82a627821614752e77b3a12d4d0021c2c6894139 +Subproject commit 9e5691f4ca06cf6ab664fc59f3dfee2ec4b0489e From bb4b6f4a381ac1913296abb03abd06400209efac Mon Sep 17 00:00:00 2001 From: IanCa Date: Mon, 24 Jun 2024 15:50:04 -0500 Subject: [PATCH 11/16] Make validation script check tsv, fix saving # in tsv --- hed/schema/__init__.py | 2 +- hed/schema/schema_io/schema2df.py | 2 +- hed/scripts/script_util.py | 10 +++++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/hed/schema/__init__.py b/hed/schema/__init__.py index 54f4b07a..937f6665 100644 --- a/hed/schema/__init__.py +++ b/hed/schema/__init__.py @@ -3,7 +3,7 @@ from .hed_schema_entry import HedSchemaEntry, UnitClassEntry, UnitEntry, HedTagEntry from .hed_schema_group import HedSchemaGroup from .hed_schema_section import HedSchemaSection -from .hed_schema_io import load_schema, load_schema_version, from_string, get_hed_xml_version +from .hed_schema_io import load_schema, load_schema_version, from_string, get_hed_xml_version, from_dataframes from .hed_schema_constants import HedKey, HedSectionKey from .hed_cache import cache_xml_versions, get_hed_versions, \ set_cache_directory, get_cache_directory diff --git a/hed/schema/schema_io/schema2df.py b/hed/schema/schema_io/schema2df.py index 9afee0a3..e2832e1a 100644 --- a/hed/schema/schema_io/schema2df.py +++ b/hed/schema/schema_io/schema2df.py @@ -95,7 +95,7 @@ def _write_tag_entry(self, tag_entry, parent_node=None, level=0): constants.hed_id: f"{tag_id}", constants.level: f"{level}", constants.name: - tag_entry.short_tag_name if not tag_entry.has_attribute(HedKey.TakesValue) + tag_entry.short_tag_name if not tag_entry.name.endswith("#") else tag_entry.short_tag_name + "-#", constants.subclass_of: self._get_subclass_of(tag_entry), constants.attributes: self._format_tag_attributes(tag_entry.attributes), diff --git a/hed/scripts/script_util.py b/hed/scripts/script_util.py index 5f54934a..3dcc85c7 100644 --- a/hed/scripts/script_util.py +++ b/hed/scripts/script_util.py @@ -1,6 +1,6 @@ import os.path from collections import defaultdict -from hed.schema import from_string, load_schema +from hed.schema import from_string, load_schema, from_dataframes from hed.errors import get_printable_issue_string, HedFileError, SchemaWarnings all_extensions = [".tsv", ".mediawiki", ".xml"] @@ -47,6 +47,14 @@ def validate_schema(file_path): error_text = f"Failed to reload {file_path} as xml. " \ f"There is either a problem with the source file, or the saving/loading code." validation_issues.append(error_text) + + tsv_dataframes = base_schema.get_as_dataframes() + reloaded_schema = from_dataframes(tsv_dataframes) + + if reloaded_schema != base_schema: + error_text = f"Failed to reload {file_path} as dataframes. " \ + f"There is either a problem with the source file, or the saving/loading code." + validation_issues.append(error_text) except HedFileError as e: print(f"Saving/loading error: {file_path} {e.message}") error_text = e.message From 179ea7800a1ea26641545ecff2ea74a866a6b22e Mon Sep 17 00:00:00 2001 From: IanCa Date: Mon, 24 Jun 2024 16:29:04 -0500 Subject: [PATCH 12/16] Improve output when schema validation fails to reload the file --- hed/scripts/script_util.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/hed/scripts/script_util.py b/hed/scripts/script_util.py index 3dcc85c7..842b5e76 100644 --- a/hed/scripts/script_util.py +++ b/hed/scripts/script_util.py @@ -2,6 +2,7 @@ from collections import defaultdict from hed.schema import from_string, load_schema, from_dataframes from hed.errors import get_printable_issue_string, HedFileError, SchemaWarnings +from hed.schema.schema_compare import compare_differences all_extensions = [".tsv", ".mediawiki", ".xml"] @@ -35,26 +36,17 @@ def validate_schema(file_path): mediawiki_string = base_schema.get_as_mediawiki_string() reloaded_schema = from_string(mediawiki_string, schema_format=".mediawiki") - if reloaded_schema != base_schema: - error_text = f"Failed to reload {file_path} as mediawiki. " \ - f"There is either a problem with the source file, or the saving/loading code." - validation_issues.append(error_text) + validation_issues += _get_schema_comparison(base_schema, reloaded_schema, file_path, "mediawiki") xml_string = base_schema.get_as_xml_string() reloaded_schema = from_string(xml_string, schema_format=".xml") - if reloaded_schema != base_schema: - error_text = f"Failed to reload {file_path} as xml. " \ - f"There is either a problem with the source file, or the saving/loading code." - validation_issues.append(error_text) + validation_issues += _get_schema_comparison(base_schema, reloaded_schema, file_path, "xml") tsv_dataframes = base_schema.get_as_dataframes() reloaded_schema = from_dataframes(tsv_dataframes) - if reloaded_schema != base_schema: - error_text = f"Failed to reload {file_path} as dataframes. " \ - f"There is either a problem with the source file, or the saving/loading code." - validation_issues.append(error_text) + validation_issues += _get_schema_comparison(base_schema, reloaded_schema, file_path, "tsv") except HedFileError as e: print(f"Saving/loading error: {file_path} {e.message}") error_text = e.message @@ -217,3 +209,15 @@ def get_prerelease_path(repo_path, schema_name, schema_version): schema_filename = get_schema_filename(schema_name, schema_version) return os.path.join(base_path, "hedtsv", schema_filename) + + +def _get_schema_comparison(schema, schema_reload, file_path, file_format): + if schema_reload != schema: + error_text = f"Failed to reload {file_path} as {file_format}. " \ + f"There is either a problem with the source file, or the saving/loading code." + title_prompt = ("If the problem is in the schema file, " + "the following comparison should indicate the approximate source of the issues:") + error_text += "\n" + compare_differences(schema, schema_reload, title=title_prompt) + return [error_text] + + return [] From 88b2ee476c071151f5f688b75e100945cc3ed4ac Mon Sep 17 00:00:00 2001 From: IanCa Date: Mon, 24 Jun 2024 18:13:05 -0500 Subject: [PATCH 13/16] Don't output empty {} in mediawiki schemas --- hed/schema/schema_io/schema2wiki.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hed/schema/schema_io/schema2wiki.py b/hed/schema/schema_io/schema2wiki.py index 3d562290..e4a8f775 100644 --- a/hed/schema/schema_io/schema2wiki.py +++ b/hed/schema/schema_io/schema2wiki.py @@ -96,14 +96,14 @@ def _add_blank_line(self): self.output.append("") def _format_props_and_desc(self, schema_entry): - prop_string = "" - tag_props = schema_entry.attributes - if tag_props: - prop_string += f"{{{self._format_tag_attributes(tag_props)}}}" + extras_string = "" + attribute_string = self._format_tag_attributes(schema_entry.attributes) + if attribute_string: + extras_string += f"{{{attribute_string}}}" desc = schema_entry.description if desc: - if tag_props: - prop_string += " " - prop_string += f"[{desc}]" + if attribute_string: + extras_string += " " + extras_string += f"[{desc}]" - return prop_string + return extras_string From a30b3c01694792286f6bc13b679bb189eb68554c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Jun 2024 11:19:23 +0000 Subject: [PATCH 14/16] Bump spec_tests/hed-specification from `052bd4a` to `5465995` Bumps [spec_tests/hed-specification](https://github.com/hed-standard/hed-specification) from `052bd4a` to `5465995`. - [Release notes](https://github.com/hed-standard/hed-specification/releases) - [Commits](https://github.com/hed-standard/hed-specification/compare/052bd4aaf39eec8c14425a71665c2264223d8c60...54659951ca1a2f5e481ef87d98d9de30036f9f56) --- updated-dependencies: - dependency-name: spec_tests/hed-specification dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- spec_tests/hed-specification | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec_tests/hed-specification b/spec_tests/hed-specification index 052bd4aa..54659951 160000 --- a/spec_tests/hed-specification +++ b/spec_tests/hed-specification @@ -1 +1 @@ -Subproject commit 052bd4aaf39eec8c14425a71665c2264223d8c60 +Subproject commit 54659951ca1a2f5e481ef87d98d9de30036f9f56 From 3f14ba6b41c7aee6cc87346999709646197d6a2c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Jun 2024 11:19:25 +0000 Subject: [PATCH 15/16] Bump spec_tests/hed-examples from `9e5691f` to `8824691` Bumps [spec_tests/hed-examples](https://github.com/hed-standard/hed-examples) from `9e5691f` to `8824691`. - [Release notes](https://github.com/hed-standard/hed-examples/releases) - [Commits](https://github.com/hed-standard/hed-examples/compare/9e5691f4ca06cf6ab664fc59f3dfee2ec4b0489e...88246912339625df9c88554071465c14eaa68396) --- updated-dependencies: - dependency-name: spec_tests/hed-examples dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- spec_tests/hed-examples | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec_tests/hed-examples b/spec_tests/hed-examples index 9e5691f4..88246912 160000 --- a/spec_tests/hed-examples +++ b/spec_tests/hed-examples @@ -1 +1 @@ -Subproject commit 9e5691f4ca06cf6ab664fc59f3dfee2ec4b0489e +Subproject commit 88246912339625df9c88554071465c14eaa68396 From e2097e9ec12f84f66587b09ff01843ea6fd58825 Mon Sep 17 00:00:00 2001 From: IanCa Date: Wed, 26 Jun 2024 11:42:40 -0500 Subject: [PATCH 16/16] Fix np.nan, add windows CI workflow --- .github/workflows/ci_windows.yaml | 42 +++++++++++++++++++ hed/tools/analysis/annotation_util.py | 4 +- hed/tools/remodeling/dispatcher.py | 2 +- .../remodeling/operations/remap_columns_op.py | 2 +- tests/tools/analysis/test_annotation_util.py | 10 ++--- 5 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/ci_windows.yaml diff --git a/.github/workflows/ci_windows.yaml b/.github/workflows/ci_windows.yaml new file mode 100644 index 00000000..278271b9 --- /dev/null +++ b/.github/workflows/ci_windows.yaml @@ -0,0 +1,42 @@ +name: CI + +on: + push: + branches: ["main", "master"] + pull_request: + branches: ["main", "master"] + +jobs: + build: + strategy: + matrix: + platform: [windows-latest] + python-version: ["3.10"] + + runs-on: ${{ matrix.platform }} + + steps: + - uses: actions/checkout@v4 + with: + submodules: false + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - uses: actions/cache@v4 + with: + path: ${{ env.pythonLocation }} + key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ hashFiles('docs/requirements.txt') }} + + - name: Install dependencies + run: | + python -m pip install --upgrade --upgrade-strategy eager pip + pip install -r requirements.txt + + - name: Test with unittest + env: + HED_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + python -m unittest diff --git a/hed/tools/analysis/annotation_util.py b/hed/tools/analysis/annotation_util.py index 015c2336..3b91efe4 100644 --- a/hed/tools/analysis/annotation_util.py +++ b/hed/tools/analysis/annotation_util.py @@ -199,7 +199,7 @@ def series_to_factor(series): series (Series) - Series to be converted to a list. Returns: - list - contains 0's and 1's, empty, 'n/a' and np.NAN are converted to 0. + list - contains 0's and 1's, empty, 'n/a' and np.nan are converted to 0. """ replaced = series.replace('n/a', False) filled = replaced.fillna(False) @@ -273,7 +273,7 @@ def to_factor(data, column=None): column (str): Optional column name if DataFrame (otherwise column 0). Returns: - list - contains 0's and 1's, empty, 'n/a' and np.NAN are converted to 0. + list - contains 0's and 1's, empty, 'n/a' and np.nan are converted to 0. """ if isinstance(data, Series): series = data diff --git a/hed/tools/remodeling/dispatcher.py b/hed/tools/remodeling/dispatcher.py index cd6b81c3..04e6d809 100644 --- a/hed/tools/remodeling/dispatcher.py +++ b/hed/tools/remodeling/dispatcher.py @@ -219,7 +219,7 @@ def post_proc_data(df): df (DataFrame): The DataFrame to be processed. Returns: - DataFrame: DataFrame with the 'np.NAN replaced by 'n/a'. + DataFrame: DataFrame with the 'np.nan replaced by 'n/a'. """ dtypes = df.dtypes.to_dict() diff --git a/hed/tools/remodeling/operations/remap_columns_op.py b/hed/tools/remodeling/operations/remap_columns_op.py index ea98d03c..d9d84215 100644 --- a/hed/tools/remodeling/operations/remap_columns_op.py +++ b/hed/tools/remodeling/operations/remap_columns_op.py @@ -134,7 +134,7 @@ def do_op(self, dispatcher, df, name, sidecar=None): """ df1 = df.copy() df1[self.source_columns] = df1[self.source_columns].replace( - np.NaN, 'n/a') + np.nan, 'n/a') for column in self.integer_sources: int_mask = df1[column] != 'n/a' df1.loc[int_mask, column] = df1.loc[int_mask, column].astype(int) diff --git a/tests/tools/analysis/test_annotation_util.py b/tests/tools/analysis/test_annotation_util.py index 384419d3..dfbea0f8 100644 --- a/tests/tools/analysis/test_annotation_util.py +++ b/tests/tools/analysis/test_annotation_util.py @@ -300,13 +300,13 @@ def test_to_factor(self): factor1 = annotation_util.to_factor(series1) self.assertEqual(len(series1), len(factor1)) self.assertEqual(sum(factor1), len(factor1)) - series2 = Series(['a', '', None, np.NAN, 'n/a']) + series2 = Series(['a', '', None, np.nan, 'n/a']) factor2 = annotation_util.to_factor(series2) self.assertEqual(len(series2), len(factor2)) self.assertEqual(sum(factor2), 1) data = { 'Name': ['Alice', '', 'n/a', 1.0], # Contains a space - 'Age': [25, np.NaN, 35, 0] + 'Age': [25, np.nan, 35, 0] } df = DataFrame(data) factor3 = annotation_util.to_factor(df, column='Name') @@ -321,7 +321,7 @@ def test_series_to_factor(self): factor1 = annotation_util.series_to_factor(series1) self.assertEqual(len(series1), len(factor1)) self.assertEqual(sum(factor1), len(factor1)) - series2 = Series(['a', '', None, np.NAN, 'n/a']) + series2 = Series(['a', '', None, np.nan, 'n/a']) factor2 = annotation_util.series_to_factor(series2) self.assertEqual(len(series2), len(factor2)) self.assertEqual(sum(factor2), 1) @@ -465,13 +465,13 @@ def test_to_factor(self): factor1 = annotation_util.to_factor(series1) self.assertEqual(len(series1), len(factor1)) self.assertEqual(sum(factor1), len(factor1)) - series2 = Series(['a', '', None, np.NAN, 'n/a']) + series2 = Series(['a', '', None, np.nan, 'n/a']) factor2 = annotation_util.to_factor(series2) self.assertEqual(len(series2), len(factor2)) self.assertEqual(sum(factor2), 1) data = { 'Name': ['Alice', '', 'n/a', 1.0], # Contains a space - 'Age': [25, np.NaN, 35, 0] + 'Age': [25, np.nan, 35, 0] } df = DataFrame(data) factor3 = annotation_util.to_factor(df, column='Name')