Skip to content

Commit bf6eb97

Browse files
committed
Changing numpy float print style to 1.13
1 parent f633676 commit bf6eb97

File tree

2 files changed

+42
-38
lines changed

2 files changed

+42
-38
lines changed

nibabel/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
# Numpy changed print options in 1.14; we can update docstrings and remove
4242
# these when our minimum for building docs exceeds that
4343
'legacy_printopt': None,
44+
'floatmode': None,
4445
}
4546

4647
def setup_package():
@@ -50,13 +51,15 @@ def setup_package():
5051
if LooseVersion(np.__version__) >= LooseVersion('1.14'):
5152
if _test_states.get('legacy_printopt') is None:
5253
_test_states['legacy_printopt'] = np.get_printoptions().get('legacy')
53-
np.set_printoptions(legacy="1.13")
54+
_test_states['floatmode'] = np.get_printoptions().get('floatmode')
55+
np.set_printoptions(legacy="1.13", floatmode='fixed')
5456

5557
def teardown_package():
5658
""" Reset print options when tests finish """
5759
import numpy as np
5860
if _test_states.get('legacy_printopt') is not None:
59-
np.set_printoptions(legacy=_test_states.pop('legacy_printopt'))
61+
np.set_printoptions(legacy=_test_states.pop('legacy_printopt'),
62+
floatmode=_test_states.pop('floatmode'))
6063

6164

6265
# module imports

nibabel/gifti/gifti.py

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -721,46 +721,46 @@ def agg_data(self, intent_code=None):
721721
When not passing anything to ``intent_code``
722722
723723
>>> surf_gii_img.agg_data() # surface file
724-
(array([[-16.07201 , -66.187515, 21.266994],
725-
[-16.705893, -66.05434 , 21.232786],
726-
[-17.61435 , -65.40164 , 21.071466]], dtype=float32), array([0, 1, 2], dtype=int32))
724+
(array([[-16.07201004, -66.18751526, 21.26699448],
725+
[-16.70589256, -66.05433655, 21.23278618],
726+
[-17.61434937, -65.40164185, 21.07146645]], dtype=float32), array([0, 1, 2], dtype=int32))
727727
>>> func_gii_img.agg_data() # functional file
728-
array([[ 545.4326 , 535.8471 , 537.5014 , ..., 540.2762 ,
729-
539.53827 , 541.3617 ],
730-
[ 640.0118 , 634.727 , 630.03784 , ..., 635.21936 ,
731-
641.19586 , 638.7647 ],
732-
[ 612.9056 , 607.3228 , 606.1355 , ..., 608.2441 ,
733-
615.8239 , 613.0585 ],
728+
array([[ 545.43261719, 535.84710693, 537.50140381, ..., 540.27618408,
729+
539.53826904, 541.36169434],
730+
[ 640.01177979, 634.72698975, 630.03784180, ..., 635.21936035,
731+
641.19586182, 638.76470947],
732+
[ 612.90557861, 607.32281494, 606.13549805, ..., 608.24407959,
733+
615.82391357, 613.05847168],
734734
...,
735-
[ 101.28482 , 101.41192 , 99.21213 , ..., 100.47232 ,
736-
99.258316, 99.440796],
737-
[ 371.81592 , 367.02896 , 363.90207 , ..., 365.52597 ,
738-
363.44937 , 363.10278 ],
739-
[ 268.6521 , 262.0212 , 259.06717 , ..., 262.5381 ,
740-
257.8245 , 259.7127 ]], dtype=float32)
735+
[ 101.28482056, 101.41191864, 99.21212769, ..., 100.47232056,
736+
99.25831604, 99.44079590],
737+
[ 371.81591797, 367.02896118, 363.90206909, ..., 365.52597046,
738+
363.44937134, 363.10278320],
739+
[ 268.65209961, 262.02120972, 259.06716919, ..., 262.53808594,
740+
257.82449341, 259.71270752]], dtype=float32)
741741
742742
When passig matching intend codes ``intent_code``
743743
744744
>>> surf_gii_img.agg_data('pointset') # surface pointset
745-
array([[-16.07201 , -66.187515, 21.266994],
746-
[-16.705893, -66.05434 , 21.232786],
747-
[-17.61435 , -65.40164 , 21.071466]], dtype=float32)
745+
array([[-16.07201004, -66.18751526, 21.26699448],
746+
[-16.70589256, -66.05433655, 21.23278618],
747+
[-17.61434937, -65.40164185, 21.07146645]], dtype=float32)
748748
>>> surf_gii_img.agg_data('triangle') # surface triangle
749749
array([0, 1, 2], dtype=int32)
750750
>>> func_gii_img.agg_data('time series') # functional file
751-
array([[ 545.4326 , 535.8471 , 537.5014 , ..., 540.2762 ,
752-
539.53827 , 541.3617 ],
753-
[ 640.0118 , 634.727 , 630.03784 , ..., 635.21936 ,
754-
641.19586 , 638.7647 ],
755-
[ 612.9056 , 607.3228 , 606.1355 , ..., 608.2441 ,
756-
615.8239 , 613.0585 ],
751+
array([[ 545.43261719, 535.84710693, 537.50140381, ..., 540.27618408,
752+
539.53826904, 541.36169434],
753+
[ 640.01177979, 634.72698975, 630.03784180, ..., 635.21936035,
754+
641.19586182, 638.76470947],
755+
[ 612.90557861, 607.32281494, 606.13549805, ..., 608.24407959,
756+
615.82391357, 613.05847168],
757757
...,
758-
[ 101.28482 , 101.41192 , 99.21213 , ..., 100.47232 ,
759-
99.258316, 99.440796],
760-
[ 371.81592 , 367.02896 , 363.90207 , ..., 365.52597 ,
761-
363.44937 , 363.10278 ],
762-
[ 268.6521 , 262.0212 , 259.06717 , ..., 262.5381 ,
763-
257.8245 , 259.7127 ]], dtype=float32)
758+
[ 101.28482056, 101.41191864, 99.21212769, ..., 100.47232056,
759+
99.25831604, 99.44079590],
760+
[ 371.81591797, 367.02896118, 363.90206909, ..., 365.52597046,
761+
363.44937134, 363.10278320],
762+
[ 268.65209961, 262.02120972, 259.06716919, ..., 262.53808594,
763+
257.82449341, 259.71270752]], dtype=float32)
764764
765765
When passing mismatching ``intent_code``, the function return a empty ``tuple``
766766
@@ -773,13 +773,14 @@ def agg_data(self, intent_code=None):
773773
the order of ``intent_code`` in the tuple
774774
775775
>>> surf_gii_img.agg_data(('pointset', 'triangle'))
776-
(array([[-16.07201 , -66.187515, 21.266994],
777-
[-16.705893, -66.05434 , 21.232786],
778-
[-17.61435 , -65.40164 , 21.071466]], dtype=float32), array([0, 1, 2], dtype=int32))
776+
(array([[-16.07201004, -66.18751526, 21.26699448],
777+
[-16.70589256, -66.05433655, 21.23278618],
778+
[-17.61434937, -65.40164185, 21.07146645]], dtype=float32), array([0, 1, 2], dtype=int32))
779+
779780
>>> surf_gii_img.agg_data(('triangle', 'pointset'))
780-
(array([0, 1, 2], dtype=int32), array([[-16.07201 , -66.187515, 21.266994],
781-
[-16.705893, -66.05434 , 21.232786],
782-
[-17.61435 , -65.40164 , 21.071466]], dtype=float32))
781+
(array([0, 1, 2], dtype=int32), array([[-16.07201004, -66.18751526, 21.26699448],
782+
[-16.70589256, -66.05433655, 21.23278618],
783+
[-17.61434937, -65.40164185, 21.07146645]], dtype=float32))
783784
"""
784785

785786
# Allow multiple intents to specify the order

0 commit comments

Comments
 (0)