Skip to content

Commit

Permalink
Merge pull request #948 from IanCa/develop
Browse files Browse the repository at this point in the history
Add 8.3.0 to built in schemas
  • Loading branch information
VisLab authored Jun 11, 2024
2 parents f27dbc2 + af07f67 commit 1bfaf2f
Show file tree
Hide file tree
Showing 17 changed files with 13,414 additions and 29 deletions.
12 changes: 8 additions & 4 deletions hed/schema/schema_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,25 +312,29 @@ def _add_suggested_tag_changes(change_dict, entry1, entry2, attribute, label):
'tag': entry1.short_tag_name})


def pretty_print_change_dict(change_dict, title="Schema changes"):
def pretty_print_change_dict(change_dict, title="Schema changes", use_markdown=True):
"""Formats the change_dict into a string.
Parameters:
change_dict(dict): The result from calling gather_schema_changes
title(str): Optional header to add, a default on will be added otherwise.
use_markdown(bool): If True, adds Markdown formatting characters to output.
Returns:
changelog(str): the changes listed out by section
"""
final_strings = []
line_prefix = " - " if use_markdown else "\t"
if change_dict:
final_strings.append(title)
final_strings.append("") # add blank line
for section_key, section_dict in change_dict.items():
name = SectionEntryNamesPlural.get(section_key, section_key)
final_strings.append(f"{name}:")
line_endings = "**" if use_markdown else ""
final_strings.append(f"{line_endings}{name}:{line_endings}")
for item in section_dict:
change, tag, change_type = item['change'], item['tag'], item['change_type']
final_strings.append(f"\t{tag} ({change_type}): {change}")
final_strings.append(f"{line_prefix}{tag} ({change_type}): {change}")
final_strings.append("")
return "\n".join(final_strings)


Expand Down
13,381 changes: 13,381 additions & 0 deletions hed/schema/schema_data/HED8.3.0.xml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/errors/test_error_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Test(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.error_handler = ErrorHandler()
cls._schema = load_schema_version("8.2.0")
cls._schema = load_schema_version("8.3.0")
pass

def test_push_error_context(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/models/test_base_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_needs_sort(self):
opened_file = TabularInput(df)
self.assertFalse(opened_file.needs_sorting)

issues = opened_file.validate(load_schema_version("8.2.0"))
issues = opened_file.validate(load_schema_version("8.3.0"))
self.assertEqual(issues[1][ErrorContext.ROW], 5)
df.at[3, "onset"] = 1.5
opened_file = TabularInput(df)
Expand All @@ -111,7 +111,7 @@ def test_needs_sort(self):
df.at[3, "onset"] = 1.0
opened_file = TabularInput(df)
self.assertTrue(opened_file.needs_sorting)
issues = opened_file.validate(load_schema_version("8.2.0"))
issues = opened_file.validate(load_schema_version("8.3.0"))
# Should still report the same issue row despite needing sorting for validation
self.assertEqual(issues[1]['code'], ValidationErrors.ONSETS_OUT_OF_ORDER)
self.assertEqual(issues[2][ErrorContext.ROW], 5)
Expand Down
2 changes: 1 addition & 1 deletion tests/models/test_basic_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setUpClass(cls):
cls.events_path = os.path.realpath(
os.path.join(bids_root_path, 'sub-002/eeg/sub-002_task-FacePerception_run-1_events.tsv'))
cls.base_input = TabularInput(cls.events_path, sidecar1_path)
cls.schema = load_schema_version("8.2.0")
cls.schema = load_schema_version("8.3.0")
cls.df = cls.base_input.series_filtered

def test_find_matching_results(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/models/test_definition_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class TestDefBase(TestHedBase):
@classmethod
def setUpClass(cls):
cls.hed_schema = load_schema_version("8.2.0")
cls.hed_schema = load_schema_version("8.3.0")

def check_def_base(self, test_strings, expected_issues):
for test_key in test_strings:
Expand Down
6 changes: 3 additions & 3 deletions tests/models/test_df_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class TestShrinkDefs(unittest.TestCase):
def setUp(self):
self.schema = load_schema_version("8.2.0")
self.schema = load_schema_version("8.3.0")

def test_shrink_defs_normal(self):
df = pd.DataFrame({"column1": ["(Def-expand/TestDefNormal,(Acceleration/2471,Action/TestDef2)),Event/SomeEvent"]})
Expand Down Expand Up @@ -67,7 +67,7 @@ def test_shrink_defs_series_placeholder(self):

class TestExpandDefs(unittest.TestCase):
def setUp(self):
self.schema = load_schema_version("8.2.0")
self.schema = load_schema_version("8.3.0")
self.def_dict = DefinitionDict(["(Definition/TestDefNormal,(Acceleration/2471,Action/TestDef2))",
"(Definition/TestDefPlaceholder/#,(Acceleration/#,Action/TestDef2))"],
hed_schema=self.schema)
Expand Down Expand Up @@ -527,7 +527,7 @@ def test_complex_scenarios_df(self):


class TestSplitDelayTags(unittest.TestCase):
schema = load_schema_version("8.2.0")
schema = load_schema_version("8.3.0")
def test_empty_series_and_onsets(self):
empty_series = pd.Series([], dtype="object")
empty_onsets = pd.Series([], dtype="float")
Expand Down
2 changes: 1 addition & 1 deletion tests/models/test_hed_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class TestHedStrings(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.schema = load_schema_version("8.2.0")
cls.schema = load_schema_version("8.3.0")

def validator_scalar(self, test_strings, expected_results, test_function):
for test_key in test_strings:
Expand Down
4 changes: 2 additions & 2 deletions tests/models/test_hed_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TestValidatorUtilityFunctions(TestHedBase):

@classmethod
def setUpClass(cls):
cls.hed_schema = load_schema_version("8.2.0")
cls.hed_schema = load_schema_version("8.3.0")

def test_if_tag_exists(self):
valid_tag1 = HedTag('Left-handed', hed_schema=self.hed_schema)
Expand Down Expand Up @@ -45,7 +45,7 @@ def test_if_tag_exists(self):
class TestSchemaUtilityFunctions(TestHedBase):
@classmethod
def setUpClass(cls):
cls.hed_schema = load_schema_version("8.2.0")
cls.hed_schema = load_schema_version("8.3.0")

def test_correctly_determine_tag_takes_value(self):
value_tag1 = HedTag('Distance/35 px', hed_schema=self.hed_schema)
Expand Down
6 changes: 3 additions & 3 deletions tests/models/test_string_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class TestHedStringSplit(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.schema = load_schema_version("8.2.0")
cls.schema = load_schema_version("8.3.0")

def check_split_base_tags(self, hed_string, base_tags, expected_string, expected_string2):
# Test case 1: remove_group=False
Expand Down Expand Up @@ -70,7 +70,7 @@ def test_case_5(self):
class TestHedStringSplitDef(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.schema = load_schema_version("8.2.0")
cls.schema = load_schema_version("8.3.0")

def check_split_def_tags(self, hed_string, def_names, expected_string, expected_string2):
# Test case 1: remove_group=False
Expand Down Expand Up @@ -133,7 +133,7 @@ def test_case_5(self):

class TestGatherDescriptions(unittest.TestCase):
def setUp(self):
self.schema = load_schema_version("8.2.0")
self.schema = load_schema_version("8.3.0")

def test_gather_single_description(self):
input_str = "Sensory-event, Description/This is a test."
Expand Down
4 changes: 2 additions & 2 deletions tests/schema/test_hed_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test_schema_compliance(self):
self.assertEqual(len(warnings), 18)

def test_bad_prefixes(self):
schema = load_schema_version(xml_version="8.2.0")
schema = load_schema_version(xml_version="8.3.0")

self.assertTrue(schema.get_tag_entry("Event"))
self.assertFalse(schema.get_tag_entry("sc:Event"))
Expand All @@ -126,7 +126,7 @@ def test_bad_prefixes(self):
self.assertFalse(schema.get_tag_entry("Event", schema_namespace='unknown'))

def test_bad_prefixes_library(self):
schema = load_schema_version(xml_version="tl:8.2.0")
schema = load_schema_version(xml_version="tl:8.3.0")

self.assertTrue(schema.get_tag_entry("tl:Event", schema_namespace="tl:"))
self.assertFalse(schema.get_tag_entry("sc:Event", schema_namespace="tl:"))
Expand Down
2 changes: 1 addition & 1 deletion tests/schema/test_hed_schema_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def test_triple_prefixes(self):
# class TestOwlBase(unittest.TestCase):
# @classmethod
# def setUpClass(cls):
# cls.base_schema = schema.load_schema_version("8.2.0")
# cls.base_schema = schema.load_schema_version("8.3.0")
#
# @with_temp_file(".owl")
# def test_schema2xml(self, filename):
Expand Down
4 changes: 2 additions & 2 deletions tests/schema/test_ontology_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def setUp(self):

def test_get_library_name_and_id_default(self):
# Test default case where no library name is provided
schema = load_schema_version("8.2.0")
schema = load_schema_version("8.3.0")
name, first_id = get_library_name_and_id(schema)
self.assertEqual(name, "Standard")
self.assertEqual(first_id, 10000)
Expand Down Expand Up @@ -145,7 +145,7 @@ def test_update_dataframes_from_schema(self):
for key, df in updated_dataframes.items():
self.assertTrue((df['test_column'] == fixed_value).all())
# this is expected to bomb horribly, since schema lacks many of the spreadsheet entries.
schema = load_schema_version("8.2.0")
schema = load_schema_version("8.3.0")
schema_dataframes_new = load_schema_version("8.3.0").get_as_dataframes()
try:
updated_dataframes = update_dataframes_from_schema(schema_dataframes_new, schema)
Expand Down
6 changes: 3 additions & 3 deletions tests/schema/test_schema_validation_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ def test_schema_version_for_library(self):
self.assertEqual(util.schema_version_for_library(schema1, ""), "8.0.0")
self.assertEqual(util.schema_version_for_library(schema1, None), "8.0.0")

schema2 = load_schema_version("8.2.0")
self.assertEqual(util.schema_version_for_library(schema2, ""), "8.2.0")
self.assertEqual(util.schema_version_for_library(schema2, None), "8.2.0")
schema2 = load_schema_version("8.3.0")
self.assertEqual(util.schema_version_for_library(schema2, ""), "8.3.0")
self.assertEqual(util.schema_version_for_library(schema2, None), "8.3.0")

schema3 = load_schema_version(["testlib_2.0.0", "score_1.1.0"])
self.assertEqual(util.schema_version_for_library(schema3, ""), "8.2.0")
Expand Down
2 changes: 1 addition & 1 deletion tests/schema/util_create_schemas.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from hed.schema import HedKey, HedSectionKey, from_string


library_schema_start = """HED library="testcomparison" version="1.1.0" withStandard="8.2.0" unmerged="true"
library_schema_start = """HED library="testcomparison" version="1.1.0" withStandard="8.3.0" unmerged="true"
'''Prologue'''
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/test_convert_and_update_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_schema_conversion_and_update(self):
self.assertEqual(schema, schema_reload2)

# Now verify after doing this again with a new schema, they're still the same.
schema = load_schema_version("8.2.0")
schema = load_schema_version("8.3.0")
schema.save_as_dataframes(tsv_filename)

filenames = [os.path.join(tsv_filename, "test_schema_Tag.tsv")]
Expand Down
2 changes: 1 addition & 1 deletion tests/validator/test_spreadsheet_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class TestSpreadsheetValidation(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.schema = load_schema_version("8.2.0")
cls.schema = load_schema_version("8.3.0")
cls.validator = SpreadsheetValidator(cls.schema)
base = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../data/')
cls.base_data_dir = base
Expand Down

0 comments on commit 1bfaf2f

Please sign in to comment.