-
Notifications
You must be signed in to change notification settings - Fork 84
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
add age__reference and adjust tests #1540
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #1540 +/- ##
==========================================
+ Coverage 91.25% 91.74% +0.48%
==========================================
Files 25 26 +1
Lines 2515 2543 +28
Branches 477 485 +8
==========================================
+ Hits 2295 2333 +38
+ Misses 139 134 -5
+ Partials 81 76 -5
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
# Conflicts: # src/pynwb/file.py
@bendichter Can you add a roundtrip test and a backwards compatibility check that checks that None is returned if |
@rly In writing this test, I came up against an error in hdmf: class TestSubjectAgeReference(TestSubjectIO):
def setUpContainer(self):
""" Return the test Subject """
return Subject(
age='P90D',
age__reference=None,
description='A rat',
genotype='WT',
sex='M',
species='Rattus norvegicus',
subject_id='RAT123',
weight='2 kg',
date_of_birth=datetime(1970, 1, 1, 12, tzinfo=tzutc()),
strain='my_strain',
) args = (<[AttributeError("'Subject' object has no attribute '_AbstractContainer__name'") raised in repr()] Subject object at 0x7fa562325130>,)
kwargs = {'age': 'P90D', 'age__reference': None, 'date_of_birth': datetime.datetime(1970, 1, 1, 12, 0, tzinfo=tzutc()), 'description': 'A rat', ...}
def _check_args(args, kwargs):
"""Parse and check arguments to decorated function. Raise warnings and errors as appropriate."""
# this function was separated from func_call() in order to make stepping through lines of code using pdb
# easier
parsed = __parse_args(
loc_val,
args[1:] if is_method else args,
kwargs,
enforce_type=enforce_type,
enforce_shape=enforce_shape,
allow_extra=allow_extra,
allow_positional=allow_positional
)
parse_warnings = parsed.get('future_warnings')
if parse_warnings:
msg = '%s: %s' % (func.__qualname__, ', '.join(parse_warnings))
warnings.warn(msg, FutureWarning)
for error_type, ExceptionType in (('type_errors', TypeError),
('value_errors', ValueError),
('syntax_errors', SyntaxError)):
parse_err = parsed.get(error_type)
if parse_err:
msg = '%s: %s' % (func.__qualname__, ', '.join(parse_err))
> raise ExceptionType(msg)
E TypeError: Subject.__init__: incorrect type for 'age__reference' (got 'NoneType', expected 'str or NoneType') It looks like docval does not accept an input of |
It looks like there is an |
@bendichter Can you add
|
tl;dr I think we should not allow the case where Explanation: Use cases:
To implement what I think the logic should be above, then on read of an NWB file, the value of age__reference when it is not in the file depends on the schema version. See the mapper code I added. |
I will add a unit test for |
@bendichter This is good to go now. Please review my changes. Note that when a user calls |
* add age__reference and adjust tests * add to CHANGELOG.md * add period * Update file.py * Update CHANGELOG.md * Update src/pynwb/file.py * add arg check for Subject. If age__reference is provided, age must also be provided * add regression test for subject age * remove raising ValueError when age is omitted * flake8 * Update CHANGELOG.md * Update CHANGELOG.md * Update src/pynwb/file.py * update to allow Subject.age__reference to be None * test for Subject.age__reference == None * Update CHANGELOG.md * Update CHANGELOG.md * use mapper to allow None * update schema * forbid passing age__reference=None to Subject.__init__ * Update comment * fix flake8 * Run backwards compat tests in coverage * Add tests for get_nwb_version * Fix flake8 * Run IO utils tests in test suite Co-authored-by: Ryan Ly <[email protected]>
companion to NeurodataWithoutBorders/nwb-schema#525