Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaaa9a95

Browse files
committed
TEST: Remove try block around dtype and dimension checks.
1 parent9da49dc commitaaa9a95

File tree

2 files changed

+15
-30
lines changed

2 files changed

+15
-30
lines changed

‎nibabel/tests/test_files_interface.py‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,9 @@ def test_files_spatialimages():
4040
aff=np.eye(4)
4141
# some Image types accept only a few datatypes and shapes
4242
# so we check and force a type change to a compatible dtype
43-
try:
44-
supported_dims=supported_dimensions(klass.header_class())
45-
iflen(arr.shape)notinsupported_dims:
46-
arr=np.ones(tuple([d+2fordinrange(supported_dims.pop())]))
47-
except:
48-
pass
43+
supported_dims=supported_dimensions(klass.header_class())
44+
iflen(arr.shape)notinsupported_dims:
45+
arr=np.ones(tuple([d+2fordinrange(supported_dims.pop())]))
4946
supported_dtypes=supported_np_types(klass.header_class())
5047
ifarr.dtypenotinsupported_dtypes:
5148
arr=arr.astype(supported_dtypes.pop())
@@ -103,12 +100,9 @@ def test_round_trip_spatialimages():
103100
aff=np.eye(4)
104101
# some Image types accept only a few datatypes and shapes
105102
# so we check and force a type change to a compatible dtype
106-
try:
107-
supported_dims=supported_dimensions(klass.header_class())
108-
iflen(data.shape)notinsupported_dims:
109-
data=np.ones(tuple([d+2fordinrange(supported_dims.pop())]))
110-
except:
111-
pass
103+
supported_dims=supported_dimensions(klass.header_class())
104+
iflen(data.shape)notinsupported_dims:
105+
data=np.ones(tuple([d+2fordinrange(supported_dims.pop())]))
112106
supported_dtypes=supported_np_types(klass.header_class())
113107
ifdata.dtypenotinsupported_dtypes:
114108
data=data.astype(supported_dtypes.pop())

‎nibabel/tests/test_image_api.py‎

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,9 @@ def validate_filenames(self, imaker, params):
294294
new_dtype=np.float32
295295
# some Image types accept only a few datatypes and shapes
296296
# so we check and force a type change to a compatible dtype
297-
try:
298-
supported_dtypes=supported_np_types(img.header_class())
299-
ifnew_dtypenotinsupported_dtypes:
300-
new_dtype=supported_dtypes.pop()
301-
except:
302-
pass
297+
supported_dtypes=supported_np_types(img.header_class())
298+
ifnew_dtypenotinsupported_dtypes:
299+
new_dtype=supported_dtypes.pop()
303300
img.set_data_dtype(new_dtype)
304301
# The bytesio_round_trip helper tests bytesio load / save via file_map
305302
rt_img=bytesio_round_trip(img)
@@ -370,19 +367,13 @@ def obj_params(self):
370367
aff=np.diag([1,2,3,1])
371368

372369
# Try to retrieve allowed dims
373-
try:
374-
supported_dims=supported_dimensions(self.header_maker())
375-
self.example_shapes= (shapeforshapeinself.example_shapes
376-
iflen(shape)insupported_dims)
377-
except:
378-
pass
370+
supported_dims=supported_dimensions(self.header_maker())
371+
self.example_shapes= (shapeforshapeinself.example_shapes
372+
iflen(shape)insupported_dims)
379373
# Try to retrieve allowed dtypes
380-
try:
381-
supported_dtypes=supported_np_types(self.header_maker())
382-
self.example_dtypes= (dtypefordtypeinself.example_dtypes
383-
ifdtypeinsupported_dtypes)
384-
except:
385-
pass
374+
supported_dtypes=supported_np_types(self.header_maker())
375+
self.example_dtypes= (dtypefordtypeinself.example_dtypes
376+
ifdtypeinsupported_dtypes)
386377

387378
defmake_imaker(arr,aff,header=None):
388379
returnlambda:self.image_maker(arr,aff,header)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp