Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Best Practices] Add check for TimeSeries unit follows CMIXF-12 convention #281

Draft
wants to merge 15 commits into
base: dev
Choose a base branch
from

Conversation

weiglszonja
Copy link
Contributor

Motivation

WIP
Proposing a new check for TimeSeries that checks if unit formatting complies with the CMIXF-12 convention.
#208

How to test the behavior?

Show here how to reproduce the new behavior (can be a bug fix or a new feature)

Checklist

  • Have you ensured the PR description clearly describes the problem and solutions?
  • Have you checked to ensure that there aren't other open or previously closed Pull Requests for the same change?
  • Is your code contribution compliant with black format? If not, simply pip install black and run black . inside your fork.
  • If this PR fixes an issue, is the first line of the PR description fix #XX where XX is the issue number?

@weiglszonja weiglszonja marked this pull request as draft October 3, 2022 13:41
@weiglszonja
Copy link
Contributor Author

Double check what can and cannot be changed for units

Best Practice: :ref:`best_practice_units_of_measurement`
"""

# Early return for arbitrary units that are unknown or unavailable.
if time_series.unit == "a.u.":
return

lexer = CMIXFLexer()
tokens = lexer.tokenize(time_series.unit)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lexer.tokenize() a generator object, when a bad character is found it immediately raises an error. e.g.

tokens = lexer.tokenize("ta")
next(tokens) 

would return the recognized token value for unit t
Token(type='UNITC', value='t', lineno=1, index=0)

next(tokens)
would return:
{ValueError}Line 1: Bad character 'a'

Comment on lines +105 to +107
* - :py:class:`~pynwb.retinotopy.AxisMap`
- "o"
- Degrees
Copy link
Contributor Author

@weiglszonja weiglszonja Oct 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not TimeSeries but I thought could be good to include for example for representing degrees?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CompassDirection is more typical for that as an example (be sure to include radians as well)

@codecov-commenter
Copy link

Codecov Report

Merging #281 (8964521) into dev (06622b7) will increase coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #281      +/-   ##
==========================================
+ Coverage   93.95%   94.02%   +0.06%     
==========================================
  Files          20       20              
  Lines        1026     1037      +11     
==========================================
+ Hits          964      975      +11     
  Misses         62       62              
Flag Coverage Δ
unittests 94.02% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
nwbinspector/checks/time_series.py 97.77% <100.00%> (+0.71%) ⬆️

@CodyCBakerPhD CodyCBakerPhD added the category: new check a new best practices check to apply to all NWBFiles and their contents label Oct 4, 2022
@bendichter
Copy link
Contributor

can we hold off on this? I don't know if we want to use CMIXF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: new check a new best practices check to apply to all NWBFiles and their contents
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Add Check]: units are in SI values
4 participants