Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/hed-standard/hed-python
Browse files Browse the repository at this point in the history
…into dev-schema
  • Loading branch information
monique2208 committed Jan 5, 2024
2 parents cb53d44 + ef91120 commit e0f90ad
Show file tree
Hide file tree
Showing 27 changed files with 456 additions and 65 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
submodules: true

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:

- name: Archive code coverage results
if: ${{matrix.python-version == '3.9'}}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: code-coverage-report
path: .coverage
Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.9

Expand All @@ -121,7 +121,7 @@ jobs:
pip install -r docs/requirements.txt
- name: Download a single artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: code-coverage-report

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/spec_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
submodules: true

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -44,13 +44,13 @@ jobs:
python -m unittest spec_tests/validate_bids.py > validate_bids_results.txt
- name: Upload error test results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: error-test-results
path: error_results.txt

- name: Upload bids test results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: bids-test-results
path: validate_bids_results.txt
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ semantic_version>=2.10.0
myst-parser>=1.0.0
Sphinx>=5.2.2
sphinx_rtd_theme>=1.0.0
wordcloud==1.9.2
wordcloud==1.9.3
22 changes: 6 additions & 16 deletions docs/source/_templates/custom-class-template.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,24 @@
.. rubric:: {{ _('Methods') }}

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

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

.. autosummary::
{% for item in attributes %}
{{ module }}.{{ objname }}.{{ item }}
{%- for item in attributes %}
{{ 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 %}
{%- for item in methods %}
.. _method-{{ item }}:

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

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

.. autoattribute:: {{ module }}.{{ objname }}.{{ item }}
Expand Down
2 changes: 1 addition & 1 deletion docs/source/_templates/custom-module-template.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
.. rubric:: {{ _('Classes') }}

.. autosummary::
:toctree:
:toctree: _generated_classes
:template: custom-class-template.rst
{% for item in classes %}
{{ item }}
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"myst_parser",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.autosectionlabel",
# "sphinx.ext.autosectionlabel",
"sphinx.ext.intersphinx",
"sphinx.ext.coverage",
"sphinx.ext.mathjax",
Expand Down
4 changes: 0 additions & 4 deletions docs/source/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ Finding help

The `HED online tools <https://hedtools.org>`_ provide an easy-to-use interface that requires no programming.

:Mailing lists and forums:

* Don't hesitate to ask questions about the python hedtools on `NeuroStars
<https://neurostars.org/tags/hedtools>`_.

:Issues and problems:
* If you notice a bug in the python hedtools code or encounter other problems using the tools, please `open an issue`_ in the
Expand Down
10 changes: 6 additions & 4 deletions hed/models/definition_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ def __init__(self, def_dicts=None, hed_schema=None):
self.add_definitions(def_dicts, hed_schema)

def add_definitions(self, def_dicts, hed_schema=None):
""" Add definitions from dict(s) to this dict.
""" Add definitions from dict(s) or strings(s) to this dict.
Parameters:
def_dicts (list, DefinitionDict, or dict): DefinitionDict or list of DefinitionDicts/strings/dicts whose
definitions should be added.
Note dict form expects DefinitionEntries in the same form as a DefinitionDict
def_dicts (list, DefinitionDict, dict, or str): DefinitionDict or list of DefinitionDicts/strings/dicts whose
definitions should be added.
Note - dict form expects DefinitionEntries in the same form as a DefinitionDict
Note - str or list of strings will parse the strings using the hed_schema.
Note - You can mix and match types, eg [DefinitionDict, str, list of str] would be valid input.
hed_schema(HedSchema or None): Required if passing strings or lists of strings, unused otherwise.
:raises TypeError:
Expand Down
2 changes: 1 addition & 1 deletion hed/models/expression_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def __init__(self, expression_string):
'"Event"' - Finds the Event tag, but not any descendent tags
'Def/DefName/*' - Find Def/DefName instances with placeholders, regardless of the value of the placeholder
`Def/DefName/*` - Find Def/DefName instances with placeholders, regardless of the value of the placeholder
'Eve*' - Find any short tags that begin with Eve*, such as Event, but not Sensory-event
Expand Down
1 change: 1 addition & 0 deletions hed/models/hed_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ def default_unit(self):
""" Get the default unit class unit for this tag.
Only a tag with a single unit class can have default units.
Returns:
unit(UnitEntry or None): the default unit entry for this tag, or None
"""
Expand Down
2 changes: 1 addition & 1 deletion hed/schema/hed_schema_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def load_schema_version(xml_version=None, xml_folder=None):
An empty string returns the latest version
A json str format is also supported,
based on the output of HedSchema.get_formatted_version
Basic format: '[schema_namespace:][library_name_][X.Y.Z]'.
Basic format: `[schema_namespace:][library_name_][X.Y.Z]`.
xml_folder (str): Path to a folder containing schema.
Returns:
Expand Down
14 changes: 8 additions & 6 deletions hed/schema/schema_attribute_validators.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"""The built-in functions to validate known attributes.
Template for the functions:
attribute_checker_template(hed_schema, tag_entry, attribute_name, possible_values):
hed_schema (HedSchema): The schema to use for validation
tag_entry (HedSchemaEntry): The schema entry for this tag.
attribute_name (str): The name of this attribute
- ``attribute_checker_template(hed_schema, tag_entry, attribute_name)``:
- ``hed_schema (HedSchema)``: The schema to use for validation.
- ``tag_entry (HedSchemaEntry)``: The schema entry for this tag.
- ``attribute_name (str)``: The name of this attribute.
Returns:
bool
"""
- ``bool``: Description of the return value.
"""

from hed.errors.error_types import SchemaWarnings, ValidationErrors, SchemaAttributeErrors
from hed.errors.error_reporter import ErrorHandler
Expand Down
10 changes: 5 additions & 5 deletions hed/schema/schema_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,14 @@ def compare_schemas(schema1, schema2, attribute_filter=HedKey.InLibrary, section
schema1 (HedSchema): The first schema to be compared.
schema2 (HedSchema): The second schema to be compared.
attribute_filter (str, optional): The attribute to filter entries by.
Entries without this attribute are skipped.
The most common use would be HedKey.InLibrary
If it evaluates to False, no filtering is performed.
Entries without this attribute are skipped.
The most common use would be HedKey.InLibrary
If it evaluates to False, no filtering is performed.
sections(list): the list of sections to compare. By default, just the tags section.
If None, checks all sections including header, prologue, and epilogue.
If None, checks all sections including header, prologue, and epilogue.
Returns:
tuple: A tuple containing four dictionaries:
tuple: A tuple containing four dictionaries:
- matches(dict): Entries present in both schemas and are equal.
- not_in_schema1(dict): Entries present in schema2 but not in schema1.
- not_in_schema2(dict): Entries present in schema1 but not in schema2.
Expand Down
2 changes: 1 addition & 1 deletion hed/tools/analysis/hed_type_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class HedTypeDefs:
def_map (dict): keys are definition names, values are dict {type_values, description, tags}
Example: A definition 'famous-face-cond' with contents
`(Condition-variable/Face-type,Description/A face that should be recognized by the
participants,(Image,(Face,Famous)))`
participants,(Image,(Face,Famous)))`
would have type_values ['face_type']. All items are strings not objects.
Expand Down
7 changes: 5 additions & 2 deletions hed/tools/analysis/key_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ def make_template(self, additional_cols=None, show_counts=True):
Parameters:
additional_cols (list or None): Optional list of additional columns to append to the returned dataframe.
show_counts (bool): If true, number of times each key combination appears is in first column
show_counts (bool): If True, number of times each key combination appears is in first column and
values are sorted in descending order by
Returns:
DataFrame: A dataframe containing the template.
Expand All @@ -79,6 +81,7 @@ def make_template(self, additional_cols=None, show_counts=True):
df[additional_cols] = 'n/a'
if show_counts:
df.insert(0, 'key_counts', self._get_counts())
df.sort_values(by=['key_counts'], inplace=True, ignore_index=True, ascending=False)
return df

def _get_counts(self):
Expand Down Expand Up @@ -142,7 +145,7 @@ def resort(self):
for index, row in self.col_map.iterrows():
key_hash = get_row_hash(row, self.key_cols)
self.map_dict[key_hash] = index

def update(self, data, allow_missing=True):
""" Update the existing map with information from data.
Expand Down
Loading

0 comments on commit e0f90ad

Please sign in to comment.