From 75280b9fb42e37a6a61e02bbd3ec5f9ed9d937fc Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 21 Feb 2020 11:00:53 +0100 Subject: [PATCH] correct conversion for python3 --- processing/post/permuteData.py | 2 +- processing/pre/seeds_fromDistribution.py | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/processing/post/permuteData.py b/processing/post/permuteData.py index a589cb6da..81af71adb 100755 --- a/processing/post/permuteData.py +++ b/processing/post/permuteData.py @@ -83,7 +83,7 @@ for name in filenames: # ------------------------------------------ assemble header --------------------------------------- - randomSeed = int(os.urandom(4).encode('hex'), 16) if options.randomSeed is None else options.randomSeed # random seed per file + randomSeed = int(os.urandom(4).hex(), 16) if options.randomSeed is None else options.randomSeed # random seed per file np.random.seed(randomSeed) table.info_append([scriptID + '\t' + ' '.join(sys.argv[1:]), diff --git a/processing/pre/seeds_fromDistribution.py b/processing/pre/seeds_fromDistribution.py index 2e8936f27..7bd97db60 100755 --- a/processing/pre/seeds_fromDistribution.py +++ b/processing/pre/seeds_fromDistribution.py @@ -1,11 +1,9 @@ #!/usr/bin/env python3 -# -*- coding: UTF-8 no BOM -*- import threading,time,os,sys,random import numpy as np from optparse import OptionParser from io import StringIO -import binascii import damask scriptName = os.path.splitext(os.path.basename(__file__))[0] @@ -16,9 +14,10 @@ currentSeedsName = None #--------------------------------------------------------------------------------------------------- class myThread (threading.Thread): - """perturbes seed in seed file, performes Voronoi tessellation, evaluates, and updates best match""" + """Perturb seed in seed file, performes Voronoi tessellation, evaluates, and updates best match.""" def __init__(self, threadID): + """Threading class with thread ID.""" threading.Thread.__init__(self) self.threadID = threadID @@ -215,7 +214,7 @@ options = parser.parse_args()[0] damask.util.report(scriptName,options.seedFile) if options.randomSeed is None: - options.randomSeed = int(binascii.hexlify(os.urandom(4)),16) + options.randomSeed = int(os.urandom(4).hex(),16) damask.util.croak(options.randomSeed) delta = (options.scale/options.grid[0],options.scale/options.grid[1],options.scale/options.grid[2]) baseFile=os.path.splitext(os.path.basename(options.seedFile))[0]