Skip to content

Commit

Permalink
Merge pull request #782 from hed-standard/develop
Browse files Browse the repository at this point in the history
Merge develop in preparation for release
  • Loading branch information
VisLab authored Oct 23, 2023
2 parents eb9a836 + 20bfa33 commit 4eaca61
Show file tree
Hide file tree
Showing 64 changed files with 1,465 additions and 494 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,29 @@ on:
branches: ["*"]

jobs:
determine_version:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
run: |
if [[ "${{ github.event_name }}" == 'push' && "${{ github.ref }}" == 'refs/heads/master' ]]; then
# Push to master branch
echo 'matrix=["3.7", "3.9", "3.10", "3.11"]' >> $GITHUB_OUTPUT
elif [[ "${{ github.event_name }}" == 'pull_request' && "${{ github.event.pull_request.base.ref }}" == 'master' ]]; then
# PR to master branch
echo 'matrix=["3.7", "3.9", "3.10", "3.11"]' >> $GITHUB_OUTPUT
else
echo 'matrix=["3.9"]' >> $GITHUB_OUTPUT
fi
build:
needs: determine_version
strategy:
matrix:
platform: [ubuntu-latest]
python-version: [3.7, 3.9]
python-version: ${{fromJson(needs.determine_version.outputs.matrix)}}

runs-on: ${{ matrix.platform }}

Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/codespell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Codespell

on:
push:
branches: [develop]
pull_request:
branches: [develop]

permissions:
contents: read

jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Codespell
uses: codespell-project/actions-codespell@v2
34 changes: 0 additions & 34 deletions docs/source/_templates/autosummary/class.rst

This file was deleted.

68 changes: 39 additions & 29 deletions docs/source/_templates/custom-class-template.rst
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
{{ fullname | escape | underline}}
{{ fullname.split('.')[-1] | escape | underline }}

.. currentmodule:: {{ module }}

.. autoclass:: {{ objname }}
:members:
:show-inheritance:
:inherited-members:

{% block methods %}
.. automethod:: __init__

{% if methods %}
.. rubric:: {{ _('Methods') }}

.. autosummary::
{% for item in methods %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block attributes %}
{% if attributes %}
.. rubric:: {{ _('Attributes') }}

.. autosummary::
{% for item in attributes %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
.. autoclass:: {{ module }}.{{ objname }}
:noindex:

.. rubric:: {{ _('Methods') }}

.. autosummary::
{% for item in methods %}
{{ module }}.{{ objname }}.{{ item }}
{%- endfor %}

.. rubric:: {{ _('Attributes') }}

.. autosummary::
{% for item in attributes %}
{{ module }}.{{ objname }}.{{ item }}
{%- endfor %}

.. toctree::
:hidden:

{% for item in methods %}
{{ fullname }}#method-{{ item }}
{%- endfor %}
{% for item in attributes %}
{{ fullname }}#attribute-{{ item }}
{%- endfor %}

{% for item in methods %}
.. _method-{{ item }}:

.. automethod:: {{ module }}.{{ objname }}.{{ item }}
{%- endfor %}

{% for item in attributes %}
.. _attribute-{{ item }}:

.. autoattribute:: {{ module }}.{{ objname }}.{{ item }}
{%- endfor %}
29 changes: 18 additions & 11 deletions docs/source/_templates/custom-module-template.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{{ fullname | escape | underline}}
{{ fullname.split('.')[-1] | escape | underline}}

.. currentmodule:: {{ module }}

.. automodule:: {{ fullname }}

Expand All @@ -14,17 +16,22 @@
{% endif %}
{% endblock %}

{% block functions %}
{% if functions %}
.. rubric:: {{ _('Functions') }}
{% block functions %}
{% if functions %}
.. rubric:: {{ _('Functions') }}

.. autosummary::
:toctree:
{% for item in functions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}
.. autosummary::
{% for item in functions %}
{{ item }}
{% endfor %}

{% for item in functions %}
.. _{{ item }}:

.. autofunction:: {{ item }}
{% endfor %}
{% endif %}
{% endblock %}

{% block classes %}
{% if classes %}
Expand Down
4 changes: 2 additions & 2 deletions docs/source/api2.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
HED API reference (Auto style)
==============================
HED API reference
=================

.. currentmodule:: hed

Expand Down
4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ Hierarchical Event Descriptor (HED) Python Tools
Note: this is a work in progress. More information is coming.

.. toctree::
:maxdepth: 4
:maxdepth: 6
:caption: Contents:

introduction.md
user_guide.rst

.. toctree::
:maxdepth: 4
:maxdepth: 6
:caption: HED Python API:

api2.rst
Expand Down
11 changes: 7 additions & 4 deletions hed/errors/error_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class SidecarErrors:

class SchemaErrors:
SCHEMA_DUPLICATE_NODE = 'SCHEMA_DUPLICATE_NODE'
SCHEMA_ATTRIBUTE_INVALID = 'SCHEMA_ATTRIBUTE_INVALID'

SCHEMA_DUPLICATE_FROM_LIBRARY = "SCHEMA_LIBRARY_INVALID"


Expand All @@ -119,19 +119,22 @@ class SchemaWarnings:
SCHEMA_CHARACTER_INVALID = "SCHEMA_CHARACTER_INVALID"
SCHEMA_INVALID_CAPITALIZATION = 'invalidCaps'
SCHEMA_NON_PLACEHOLDER_HAS_CLASS = 'SCHEMA_NON_PLACEHOLDER_HAS_CLASS'
SCHEMA_INVALID_ATTRIBUTE = "SCHEMA_INVALID_ATTRIBUTE"


class SchemaAttributeErrors:
SCHEMA_ATTRIBUTE_INVALID = 'SCHEMA_ATTRIBUTE_INVALID'
SCHEMA_ATTRIBUTE_VALUE_INVALID = 'SCHEMA_ATTRIBUTE_VALUE_INVALID'
SCHEMA_DEPRECATED_INVALID = "SCHEMA_DEPRECATED_INVALID"
SCHEMA_SUGGESTED_TAG_INVALID = "SCHEMA_SUGGESTED_TAG_INVALID"
SCHEMA_RELATED_TAG_INVALID = "SCHEMA_RELATED_TAG_INVALID"

SCHEMA_UNIT_CLASS_INVALID = "SCHEMA_UNIT_CLASS_INVALID"
SCHEMA_VALUE_CLASS_INVALID = "SCHEMA_VALUE_CLASS_INVALID"
SCHEMA_ALLOWED_CHARACTERS_INVALID = "SCHEMA_ALLOWED_CHARACTERS_INVALID"
SCHEMA_IN_LIBRARY_INVALID = "SCHEMA_IN_LIBRARY_INVALID"

SCHEMA_DEFAULT_UNITS_INVALID = "SCHEMA_DEFAULT_UNITS_INVALID"
SCHEMA_CHILD_OF_DEPRECATED = "SCHEMA_CHILD_OF_DEPRECATED" # Reported as SCHEMA_DEPRECATED_INVALID
SCHEMA_CHILD_OF_DEPRECATED = "SCHEMA_CHILD_OF_DEPRECATED"
SCHEMA_CONVERSION_FACTOR_NOT_POSITIVE = "SCHEMA_CONVERSION_FACTOR_NOT_POSITIVE"


class DefinitionErrors:
Expand Down
17 changes: 9 additions & 8 deletions hed/errors/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ class HedExceptions:
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'
SCHEMA_HEADER_MISSING = 'SCHEMA_HEADER_INVALID'
SCHEMA_HEADER_INVALID = 'SCHEMA_HEADER_INVALID'
SCHEMA_UNKNOWN_HEADER_ATTRIBUTE = "SCHEMA_HEADER_INVALID"

SCHEMA_LIBRARY_INVALID = "SCHEMA_LIBRARY_INVALID"
BAD_HED_LIBRARY_NAME = 'SCHEMA_LIBRARY_INVALID'
Expand All @@ -26,14 +27,14 @@ class HedExceptions:
ROOTED_TAG_DOES_NOT_EXIST = "SCHEMA_LIBRARY_INVALID"
IN_LIBRARY_IN_UNMERGED = "SCHEMA_LIBRARY_INVALID"

HED_SCHEMA_VERSION_INVALID = 'HED_SCHEMA_VERSION_INVALID'
SCHEMA_START_MISSING = 'HED_WIKI_SEPARATOR_INVALID'
SCHEMA_END_INVALID = 'HED_WIKI_SEPARATOR_INVALID'
HED_END_INVALID = 'HED_WIKI_SEPARATOR_INVALID'
INVALID_SECTION_SEPARATOR = 'invalidSectionSeparator'
SCHEMA_VERSION_INVALID = 'SCHEMA_VERSION_INVALID'
SCHEMA_SECTION_MISSING = 'SCHEMA_SECTION_MISSING'

WIKI_SEPARATOR_INVALID = 'invalidSectionSeparator'

# This issue will contain a list of lines with issues.
HED_WIKI_DELIMITERS_INVALID = 'HED_WIKI_DELIMITERS_INVALID'
WIKI_DELIMITERS_INVALID = 'WIKI_DELIMITERS_INVALID'
WIKI_LINE_START_INVALID = 'WIKI_LINE_START_INVALID'
HED_SCHEMA_NODE_NAME_INVALID = 'HED_SCHEMA_NODE_NAME_INVALID'

SCHEMA_DUPLICATE_PREFIX = 'schemaDuplicatePrefix'
Expand Down
1 change: 1 addition & 0 deletions hed/errors/known_error_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
],
"schema_validation_errors": [
"SCHEMA_ATTRIBUTE_INVALID",
"SCHEMA_ATTRIBUTE_VALUE_INVALID",
"SCHEMA_CHARACTER_INVALID",
"SCHEMA_DUPLICATE_NODE",
"SCHEMA_HEADER_INVALID",
Expand Down
39 changes: 26 additions & 13 deletions hed/errors/schema_error_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def schema_error_hed_duplicate_from_library(tag, duplicate_tag_list, section):
f"{tag_join_delimiter}{tag_join_delimiter.join(duplicate_tag_list)}"


@hed_error(SchemaErrors.SCHEMA_ATTRIBUTE_INVALID)
@hed_error(SchemaAttributeErrors.SCHEMA_ATTRIBUTE_INVALID)
def schema_error_unknown_attribute(attribute_name, source_tag):
return f"Attribute '{attribute_name}' used by '{source_tag}' was not defined in the schema, " \
f"or was used outside of it's defined class."
Expand All @@ -40,45 +40,58 @@ def schema_warning_SCHEMA_INVALID_CAPITALIZATION(tag_name, problem_char, char_in
f"Found character '{problem_char}' in tag '{tag_name}' at position {char_index}."


@hed_error(SchemaWarnings.SCHEMA_NON_PLACEHOLDER_HAS_CLASS, default_severity=ErrorSeverity.WARNING)
@hed_error(SchemaWarnings.SCHEMA_NON_PLACEHOLDER_HAS_CLASS, default_severity=ErrorSeverity.WARNING,
actual_code=SchemaAttributeErrors.SCHEMA_ATTRIBUTE_VALUE_INVALID)
def schema_warning_non_placeholder_class(tag_name, invalid_attribute_name):
return "Only placeholder nodes('#') can have a unit class, value class, or takes value." + \
f"Found {invalid_attribute_name} on {tag_name}"


@hed_error(SchemaWarnings.SCHEMA_INVALID_ATTRIBUTE, default_severity=ErrorSeverity.ERROR)
def schema_error_SCHEMA_INVALID_ATTRIBUTE(tag_name, invalid_attribute_name):
return f"'{invalid_attribute_name}' should not be present in a loaded schema, found on '{tag_name}'." \
f"Something went very wrong."


@hed_error(SchemaAttributeErrors.SCHEMA_DEPRECATED_INVALID)
@hed_error(SchemaAttributeErrors.SCHEMA_DEPRECATED_INVALID, actual_code=SchemaAttributeErrors.SCHEMA_ATTRIBUTE_VALUE_INVALID)
def schema_error_SCHEMA_DEPRECATED_INVALID(tag_name, invalid_deprecated_version):
return f"'{tag_name}' has invalid or unknown value in attribute deprecatedFrom: '{invalid_deprecated_version}'."


@hed_error(SchemaAttributeErrors.SCHEMA_CHILD_OF_DEPRECATED,
actual_code=SchemaAttributeErrors.SCHEMA_DEPRECATED_INVALID)
actual_code=SchemaAttributeErrors.SCHEMA_ATTRIBUTE_VALUE_INVALID)
def schema_error_SCHEMA_CHILD_OF_DEPRECATED(deprecated_tag, non_deprecated_child):
return f"Deprecated tag '{deprecated_tag}' has a child that is not deprecated: '{non_deprecated_child}'."


@hed_error(SchemaAttributeErrors.SCHEMA_SUGGESTED_TAG_INVALID)
@hed_error(SchemaAttributeErrors.SCHEMA_SUGGESTED_TAG_INVALID, actual_code=SchemaAttributeErrors.SCHEMA_ATTRIBUTE_VALUE_INVALID)
def schema_error_SCHEMA_SUGGESTED_TAG_INVALID(suggestedTag, invalidSuggestedTag, attribute_name):
return f"Tag '{suggestedTag}' has an invalid {attribute_name}: '{invalidSuggestedTag}'."


@hed_error(SchemaAttributeErrors.SCHEMA_UNIT_CLASS_INVALID)
@hed_error(SchemaAttributeErrors.SCHEMA_UNIT_CLASS_INVALID, actual_code=SchemaAttributeErrors.SCHEMA_ATTRIBUTE_VALUE_INVALID)
def schema_error_SCHEMA_UNIT_CLASS_INVALID(tag, unit_class, attribute_name):
return f"Tag '{tag}' has an invalid {attribute_name}: '{unit_class}'."


@hed_error(SchemaAttributeErrors.SCHEMA_VALUE_CLASS_INVALID)
@hed_error(SchemaAttributeErrors.SCHEMA_VALUE_CLASS_INVALID, actual_code=SchemaAttributeErrors.SCHEMA_ATTRIBUTE_VALUE_INVALID)
def schema_error_SCHEMA_VALUE_CLASS_INVALID(tag, unit_class, attribute_name):
return f"Tag '{tag}' has an invalid {attribute_name}: '{unit_class}'."


@hed_error(SchemaAttributeErrors.SCHEMA_DEFAULT_UNITS_INVALID)
@hed_error(SchemaAttributeErrors.SCHEMA_DEFAULT_UNITS_INVALID, actual_code=SchemaAttributeErrors.SCHEMA_ATTRIBUTE_VALUE_INVALID)
def schema_error_SCHEMA_DEFAULT_UNITS_INVALID(tag, bad_unit, valid_units):
valid_units = ",".join(valid_units)
return f"Tag '{tag}' has an invalid defaultUnit '{bad_unit}'. Valid units are: '{valid_units}'."


@hed_error(SchemaAttributeErrors.SCHEMA_CONVERSION_FACTOR_NOT_POSITIVE, actual_code=SchemaAttributeErrors.SCHEMA_ATTRIBUTE_VALUE_INVALID)
def schema_error_SCHEMA_CONVERSION_FACTOR_NOT_POSITIVE(tag, conversion_factor):
return f"Tag '{tag}' has an invalid conversionFactor '{conversion_factor}'. Conversion factor must be positive."


@hed_error(SchemaAttributeErrors.SCHEMA_ALLOWED_CHARACTERS_INVALID, actual_code=SchemaAttributeErrors.SCHEMA_ATTRIBUTE_VALUE_INVALID)
def schema_error_SCHEMA_ALLOWED_CHARACTERS_INVALID(tag, invalid_character):
return (f"Tag '{tag}' has an invalid allowedCharacter: '{invalid_character}'. "
f"Allowed characters are: a single character, "
f"or one of the following - letters, blank, digits, alphanumeric.")


@hed_error(SchemaAttributeErrors.SCHEMA_IN_LIBRARY_INVALID, actual_code=SchemaAttributeErrors.SCHEMA_ATTRIBUTE_VALUE_INVALID)
def schema_error_SCHEMA_IN_LIBRARY_INVALID(tag, bad_library):
return (f"Tag '{tag}' has an invalid inLibrary: '{bad_library}'. ")
2 changes: 1 addition & 1 deletion hed/models/base_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def _indexed_dict_from_onsets(onsets):

@staticmethod
def _filter_by_index_list(original_series, indexed_dict):
new_series = ["n/a"] * len(original_series) # Initialize new_series with "n/a"
new_series = pd.Series(["n/a"] * len(original_series), dtype=str)

for onset, indices in indexed_dict.items():
if indices:
Expand Down
Loading

0 comments on commit 4eaca61

Please sign in to comment.