Skip to content

Conversation

@effigies
Copy link
Member

CI is failing. None of these cases seemed to hinge on the exact semantics of LooseVersion. In most cases, packaging.version.Version works as well. For CIFTI-2, the spec says the string must be "2", so let's not parse that unless tests show we've been explicitly trying to be flexible there.

@codecov
Copy link

codecov bot commented Jan 20, 2022

Codecov Report

Merging #1073 (c7f4a3a) into master (14db79e) will increase coverage by 0.41%.
The diff coverage is 92.06%.

❗ Current head c7f4a3a differs from pull request most recent head 4fee9af. Consider uploading reports for the commit 4fee9af to get more accurate results

Impacted file tree graph

@@ Coverage Diff @@ ## master #1073 +/- ## ========================================== + Coverage 91.87% 92.28% +0.41%  ========================================== Files 101 100 -1 Lines 12551 12222 -329 Branches 2406 2388 -18 ========================================== - Hits 11531 11279 -252  + Misses 683 619 -64  + Partials 337 324 -13 
Impacted Files Coverage Δ
nibabel/__init__.py 100.00% <ø> (ø)
nibabel/affines.py 100.00% <ø> (ø)
nibabel/arrayproxy.py 100.00% <ø> (+0.75%) ⬆️
nibabel/batteryrunners.py 95.83% <ø> (ø)
nibabel/casting.py 86.32% <ø> (ø)
nibabel/cmdline/dicomfs.py 18.96% <0.00%> (ø)
nibabel/cmdline/diff.py 93.70% <0.00%> (ø)
nibabel/conftest.py 100.00% <ø> (ø)
nibabel/dataobj_images.py 98.36% <ø> (+1.48%) ⬆️
nibabel/ecat.py 88.34% <ø> (+0.27%) ⬆️
... and 50 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1eb21d8...4fee9af. Read the comment docs.

Copy link
Member

@matthew-brett matthew-brett left a comment

Choose a reason for hiding this comment

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

Harmonize Cifti with other Version calls?

self.header = Cifti2Header()
self.header.version = attrs['Version']
if LooseVersion(self.header.version) < LooseVersion('2'):
if self.header.version not in ("2", "2.0"):
Copy link
Member

Choose a reason for hiding this comment

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

Is that right - that these are the only possible spellings for the version >= 2? What about versions > 2? Why not use Version('2') here instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Can restore rough equivalence, just unclear why to expect future versions to be parseable by the same parser.

Copy link
Member

Choose a reason for hiding this comment

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

Do we have some reason to think that Cifti versions won't be in standard version format? Or, put another way, what's the advantage of restricting ourselves to the strings here?

Copy link
Member

Choose a reason for hiding this comment

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

If you think it's likely that Cifti will go to some other version convention, we can just stick with the string comparison and run an error?

@effigies
Copy link
Member Author

Do we have some reason to think that Cifti versions won't be in standard version format? Or, put another way, what's the advantage of restricting ourselves to the strings here?

The spec requires it to be "2":

CIFTI Element

  • Description – The root of the CIFTI XML.
  • Attributes
    • Version – Indicates version of the CIFTI XML. For CIFTI-2, this must have the value “2”. If the value is “1” or “1.0”, this document does not apply, and instead the file should follow the CIFTI-1 specification: http://www.nitrc.org/plugins/mwiki/index.php/cifti:MainPage. It should be noted that CIFTI-2 compliant software is not required to be able to read CIFTI-1.

Our tests explicitly check a file with "2.0" in it, and it seems reasonable to continue with that. It's unclear whether it's a good idea to support undefined version declarations like "2.1" or "3.0", but at least it's not a regression to permit them. I'm a little inclined to emit a warning like "Unknown CIFTI version {ver}; will attempt to parse as CIFTI-2".

I switched to packaging.version.parse. If that fails to produce a Version() object, it will produce a LegacyVersion() that always compares less than any Version(), so this check should remain flexible.

@effigies
Copy link
Member Author

Pre-release failures are related to numpy/numpy#20863.

Notes on CIFTI version parsing: 1) The spec only permits "2", but we have found "2.0". 2) Use packaging.version.parse to allow for non-PEP440 style strings. These will always resolve as < a PEP440 version, so the check will permit strings like "2.1" and "3.0" but not "tag2.0" or "1".
@effigies
Copy link
Member Author

effigies commented Feb 7, 2022

Merging to get tests working. If we want to bikeshed the CIFTI2 version check, we can do it in another PR.

@effigies effigies merged commit 4ecf756 into nipy:master Feb 7, 2022
@effigies effigies deleted the mnt/drop_distutils branch February 16, 2022 22:01
@effigies effigies mentioned this pull request Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants