Skip to content

Commit

Permalink
[change] rev_eng change
Browse files Browse the repository at this point in the history
  • Loading branch information
dvolgyes committed Apr 20, 2017
1 parent 5ed4417 commit d8dcd5b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@ script:

after_success:
- coveralls
- codecov
26 changes: 11 additions & 15 deletions perceptionmd/utils/rev_eng.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,20 @@ def detect_shape(inputdata, dtype=np.float32, threeD=True):
def divisors(n, trivial=False):
large = []
small = []
if trivial:
for i in xrange(1, int(np.sqrt(n) + 1)):
if n % i == 0:
small.append(i)
if i * i != n:
large.append(n / i)
else:
for i in xrange(2, int(np.sqrt(n) + 1)):
if n % i == 0:
small.append(i)
if i * i != n:
large.append(int(n / i))
for i in xrange(2, int(np.sqrt(n) + 1)):
if n % i == 0:
small.append(i)
if i * i != n:
large.append(int(n / i))
return small + large[::-1]

def getOffset(array, minium_data=3):
if array.size < minium_data:
return 1

divs = divisors(array.size, trivial=False)
divs = divisors(array.size)

if len(divs) == 2:
if len(divs) == 0:
return 1

a = array.ravel()
Expand Down Expand Up @@ -113,7 +106,10 @@ def getOffset(array, minium_data=3):
shape = (-1,) + a + b
data = np.squeeze(data.reshape(shape))
if len(data.shape) == 2 and threeD:
return data.reshape(-1, data.shape[1], data.shape[1])
try:
return data.reshape(-1, data.shape[1], data.shape[1])
except:
return data.reshape(1, data.shape[0], data.shape[1])
return data


Expand Down

0 comments on commit d8dcd5b

Please sign in to comment.