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

lambda x, y: x * yoperator.mul #102

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion spec2nii/fileiobase.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import os
import string
import itertools
import operator
from functools import reduce

import numpy as np
Expand Down Expand Up @@ -511,7 +512,7 @@ def index2trace_flat(shape, index):
# by the corresponding index element, index[-1] as added at the beginning
a = index[-1]
for i, v in enumerate(index[:-1]):
mult = reduce(lambda x, y: x * y, shape[i + 1:])
mult = reduce(operator.mul, shape[i + 1:])
a = a + mult * v
return a

Expand Down
7 changes: 4 additions & 3 deletions spec2nii/varian.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import os
import struct
import inspect
import operator
from warnings import warn
from functools import reduce

Expand Down Expand Up @@ -659,7 +660,7 @@ def order_data(data, torder):

"""
# determine the shape of the on disk data matrix
ntraces = reduce(lambda x, y: x * y, data.shape[:-1])
ntraces = reduce(operator.mul, data.shape[:-1])
nshape = (ntraces, data.shape[-1])

# take care of flat files
Expand Down Expand Up @@ -1044,7 +1045,7 @@ def write_fid_lowmem(filename, dic, data, torder='f', repack=False, correct=True
warn("data and np size mismatch")
if correct:
dic['np'] = int(data.shape[1] * 2)
nblocks = int(reduce(lambda x, y: x * y, data.shape[:-1]))
nblocks = int(reduce(operator.mul, data.shape[:-1]))
if nblocks != dic["nblocks"]:
warn("data and block size mismatch")
if correct:
Expand Down Expand Up @@ -2067,7 +2068,7 @@ def __init__(self, filename, i2t_func, fshape=None, order=None):
s = "last dimension should have size %i" % (int(dic["np"] / 2))
raise ValueError(s)
# product of all but last dim should be number of blocks
if reduce(lambda x, y: x * y, fshape[:-1]) != dic['nblocks']:
if reduce(operator.mul, fshape[:-1]) != dic['nblocks']:
s = "number of traces in file does not match fshape"
raise ValueError(s)

Expand Down
Loading