Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Release 0.3.1 July 3, 2023
- Pinned the version of the pydantic and inflect libraries due to inflict.
- Reorganized JSON output of remodeling summaries so that all of consistent form.
- Fixed summarize_hed_tags_op so that tags were correctly categorized for output.
- Minor refactoring to reduce code complexity.
- BaseInput and Sidecar now raise HedFileError if input could not be read.


Release 0.3.0 June 20, 2023
- Introduction of partnered schema.
- Improved error handling for schema validation.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MIT License
The MIT License (MIT)

Copyright (c) 2020+ HED Standard Working Group

Expand Down
2 changes: 1 addition & 1 deletion hed/errors/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class HedExceptions:
INVALID_EXTENSION = 'invalidExtension'

INVALID_DATAFRAME = 'INVALID_DATAFRAME'

INVALID_FILE_FORMAT = 'INVALID_FILE_FORMAT'
# These are actual schema issues, not that the file cannot be found or parsed
SCHEMA_HEADER_MISSING = 'HED_SCHEMA_HEADER_INVALID'
HED_SCHEMA_HEADER_INVALID = 'HED_SCHEMA_HEADER_INVALID'
Expand Down
8 changes: 5 additions & 3 deletions hed/models/base_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def __init__(self, file, file_type=None, worksheet_name=None, has_column_names=T
- A duplicate or empty column name appears
- Cannot open the indicated file
- The specified worksheet name does not exist
- If the sidecar file or tabular file had invalid format and could not be read.

"""
if mapper is None:
mapper = ColumnMapper()
Expand Down Expand Up @@ -77,7 +79,7 @@ def __init__(self, file, file_type=None, worksheet_name=None, has_column_names=T
self._dataframe = pandas.read_csv(file, delimiter='\t', header=pandas_header,
dtype=str, keep_default_na=True, na_values=None)
except Exception as e:
raise HedFileError(HedExceptions.GENERIC_ERROR, str(e), self.name) from e
raise HedFileError(HedExceptions.INVALID_FILE_FORMAT, str(e), self.name) from e
# Convert nan values to a known value
self._dataframe = self._dataframe.fillna("n/a")
elif input_type in self.EXCEL_EXTENSION:
Expand All @@ -96,7 +98,7 @@ def __init__(self, file, file_type=None, worksheet_name=None, has_column_names=T
# todo: Can we get rid of this behavior now that we're using pandas?
column_issues = ColumnMapper.check_for_blank_names(self.columns, allow_blank_names=allow_blank_names)
if column_issues:
raise HedFileError(HedExceptions.BAD_COLUMN_NAMES, "Duplicate or blank columns found. See issues.",
raise HedFileError(HedExceptions.BAD_COLUMN_NAMES, "Duplicate or blank columns found. See issues.",
self.name, issues=column_issues)

self.reset_mapper(mapper)
Expand Down Expand Up @@ -287,7 +289,7 @@ def set_cell(self, row_number, column_number, new_string_obj, tag_form="short_ta

Notes:
Any attribute of a HedTag that returns a string is a valid value of tag_form.

:raises ValueError:
- There is not a loaded dataframe

Expand Down
6 changes: 2 additions & 4 deletions hed/models/sidecar.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,13 @@ def load_sidecar_file(self, file):
if not file:
return {}
elif isinstance(file, str):
if not self.name:
self.name = file
try:
with open(file, "r") as fp:
if not self.name:
self.name = file
return self._load_json_file(fp)
except OSError as e:
raise HedFileError(HedExceptions.FILE_NOT_FOUND, e.strerror, file) from e
except TypeError as e:
raise HedFileError(HedExceptions.FILE_NOT_FOUND, str(e), file) from e
else:
return self._load_json_file(file)

Expand Down