Commit 2aaf1e86 authored by Edward Andò's avatar Edward Andò
Browse files

__future__ gone, coverage should now work in multiprocessing functions

parent ec824efb
Pipeline #64892 passed with stages
in 12 minutes and 51 seconds
......@@ -12,13 +12,10 @@ exclude_lines =
def create2Patche*
def create8Patche*
raise InputError
if verbose:
[run]
omit =
*/__init__.py
*/*Toolkit.py
*/_*
*/plotting/*
*optionsParser.py
......
......@@ -43,6 +43,7 @@ pages:
- coverage run -m pytest
- coverage combine && coverage report
- coverage html
#- pytest --cov-report html --cov=spam tools/tests/ ## This is with pytest-cov
- mv coverage public
artifacts:
paths:
......
......@@ -7,6 +7,7 @@ sphinx-gallery==0.8.2 # Python >=3.5
sphinx_rtd_theme==0.5.1
twine==3.4.1 # Python >=3.6
pytest==3.6 # Python >=3.6
# pytest-cov==2.11.1 # This is for test coverage with multiprocessing?
# Pillow for osx version 5.0.1 is bugged
# it is used by sphinx
......
......@@ -288,6 +288,8 @@ with multiprocessing.Pool(processes=args.PROCESSES) as pool:
pixelSearchCC[returns[0]] = returns[2]
error[returns[0]] = returns[3]
returnStatus[returns[0]] = returns[4]
pool.close()
pool.join()
pbar.finish()
......
......@@ -17,8 +17,6 @@ this program. If not, see <http://www.gnu.org/licenses/>.
"""
# 2017-05-29 ER and EA
from __future__ import print_function
# This is spam's C++ DIC toolkit, but since we're in the tools/ directory we can import it directly
from . import DICToolkit
......
......@@ -20,8 +20,6 @@ this program. If not, see <http://www.gnu.org/licenses/>.
# 2017-05-29 ER and EA
from __future__ import print_function
import scipy.ndimage
import numpy
......
......@@ -16,7 +16,6 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import print_function
import numpy
import scipy.ndimage
#numpy.set_printoptions(precision=3, suppress=True)
......
......@@ -170,6 +170,8 @@ def estimateLocalQuadraticCoherency(points, displacements, neighbourRadius=150,
finishedPoints += 1
pbar.update(finishedPoints)
LQC[returns[0]] = returns[1]
pool.close()
pool.join()
if verbose: pbar.finish()
......@@ -340,6 +342,8 @@ def estimateDisplacementFromQuadraticFit(points, displacements, coherency, coher
finishedPoints += 1
pbar.update(finishedPoints)
displacementsBad[returns[0]] = returns[1]
pool.close()
pool.join()
if verbose: pbar.finish()
......
......@@ -153,6 +153,8 @@ def FfieldRegularQ8(displacementField, nodeSpacing, nProcesses=nProcessesDefault
finishedCells += 1
pbar.update(finishedCells)
FfieldFlat[returns[0]] = returns[1]
pool.close()
pool.join()
if verbose: pbar.finish()
......@@ -468,6 +470,8 @@ def FfieldBagi(points, connectivity, displacements, nProcesses=nProcessesDefault
finishedTets += 1
pbar.update(finishedTets)
Ffield[returns[0]] = returns[1]
pool.close()
pool.join()
if verbose: pbar.finish()
......@@ -552,6 +556,8 @@ def decomposeFfield(Ffield, components, twoD=False, nProcesses=nProcessesDefault
pbar.update(finishedPoints)
for component in components:
output[component][returns[0]] = returns[1][component]
pool.close()
pool.join()
if verbose: pbar.finish()
......@@ -648,6 +654,8 @@ def decomposePhiField(PhiField, components, twoD=False, nProcesses=nProcessesDef
pbar.update(finishedPoints)
for component in components:
output[component][returns[0]] = returns[1][component]
pool.close()
pool.join()
if verbose: pbar.finish()
......
......@@ -17,7 +17,6 @@ this program. If not, see <http://www.gnu.org/licenses/>.
"""
# 2020-02-24 Olga Stamati and Edward Ando
from __future__ import print_function
import numpy
import scipy.ndimage
......
......@@ -16,7 +16,6 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import print_function
import numpy
from scipy.constants import pi
......
......@@ -16,8 +16,6 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import print_function
import numpy
import tifffile
import spam.helpers
......
......@@ -351,6 +351,8 @@ def directionalErosion(bwIm, vect, a, c, nProcesses=nProcessesDefault, verbose =
widgets[0] = progressbar.FormatLabel("{}/{} ".format(finishedNodes, numberOfJobs))
pbar.update(finishedNodes)
imEroded = imEroded + returns
pool.close()
pool.join()
if verbose:
pbar.finish()
......
from __future__ import print_function
import matplotlib.pyplot as plt
import numpy
......
......@@ -16,8 +16,6 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import print_function
import numpy
import tifffile
......
......@@ -16,7 +16,6 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import print_function
import numpy
import os
......
......@@ -16,7 +16,6 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import print_function
import numpy
from . import kalispheraToolkit
......
......@@ -16,8 +16,6 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import print_function
from . import labelToolkit
import numpy
......@@ -929,7 +927,6 @@ def localDetectionAssembly(volLab, volGrey, contactList, localThreshold, boundin
if contact == True:
#print ("we are in contact!")
return job, grainA, grainB
#qResults.put( [ workerNumber, job, grainA, grainB ] )
# Create progressbar
widgets = [progressbar.FormatLabel(''), ' ', progressbar.Bar(), ' ', progressbar.AdaptiveETA()]
......@@ -945,6 +942,8 @@ def localDetectionAssembly(volLab, volGrey, contactList, localThreshold, boundin
pbar.update(finishedNodes)
if returns is not None:
contactListRefined.append( [ returns[1], returns[2] ] )
pool.close()
pool.join()
# End progressbar
......@@ -1043,76 +1042,11 @@ def contactOrientationsAssembly(volLab, volGrey, contactList, watershed="ITK", p
if returns is not None:
contactOrientations.append( [ returns[0], returns[1], returns[2], returns[3], returns[4], returns[5] ] )
#result[2], result[3], result[4], result[5], result[6], result[7]
pool.close()
pool.join()
# End progressbar
pbar.finish()
return numpy.asarray(contactOrientations)
#def worker(workerNumber, qJobs, qResults):
#while True:
#job = qJobs.get()
#if job == "STOP":
#qResults.put("STOP")
#break
#2020-03-10 GP and EA: Too much output is as useful as no output...
#else:
#print ("\tWorking on job #", job , " of " , numberOfJobs)
#grainA, grainB = contactList[job,0:2].astype('int')
#labels = [grainA, grainB]
#subVolLab, subVolBin, subVolGrey = fetchTwoGrains(volLab, volGrey, labels, boundingBoxes)
#contactNormal, intervox, NotTreatedContact = spam.label.contactOrientations(subVolBin, subVolLab, watershed, peakDistance=peakDistance, verbose=verbose)
#TODO work on not treated contacts -- output them!
#qResults.put( [ workerNumber, job+1, grainA, grainB, contactNormal[0], contactNormal[1], contactNormal[2], intervox ] )
#startTime = time.time()
#print "Master: Setting up queues"
#qJobs = multiprocessing.Queue()
#qResults = multiprocessing.Queue()
#print "Master: Adding jobs to queues"
#for x in range(numberOfJobs):
#qJobs.put( contactList[x,0] )
#qJobs.put(x)
#for i in range(numberOfThreads):
#qJobs.put("STOP")
#print "Master: Launching workers"
#for i in range(numberOfThreads):
#p = multiprocessing.Process(target=worker, args=(i, qJobs, qResults, ))
#p.start()
#pbar = progressbar.ProgressBar(maxval=numberOfJobs).start()
#finishedThreads = 0
#finishedJobs = 0
#print "Master: Waiting for results"
#while finishedThreads < numberOfThreads:
#result = qResults.get()
#if result == "STOP":
#finishedThreads += 1
#print("\tNumber of finished threads = ", finishedThreads)
#else:
#print "Master: got {}".format( result )
#contactOrientations.append([result[2], result[3], result[4], result[5], result[6], result[7]])
#finishedJobs += 1
#pbar.update(finishedJobs)
#pbar.finish()
#timeTotal = time.time() - startTime
#print("\tfinished after ... ", timeTotal, " s")
#return numpy.asarray(contactOrientations)
......@@ -16,8 +16,6 @@ You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import print_function
import numpy
import sys
......@@ -1675,6 +1673,8 @@ def convexVolume(lab, boundingBoxes=None, centresOfMass=None, volumes=None, nPro
widgets[0] = progressbar.FormatLabel(" vol={:0>7.5f} ".format(returns[1]))
pbar.update(finishedNodes)
convexVolume[returns[0]] = returns[1]
pool.close()
pool.join()
if verbose:
pbar.finish()
......@@ -1840,6 +1840,8 @@ def moveLabels(lab, PhiField, returnStatus = None, boundingBoxes=None, centresOf
# Set voxels in slice to the value of the label if not in greyscale mode
if returns[0] > 0:
labOut[returns[1]][returns[2]] = returns[0]
pool.close()
pool.join()
# End progressbar
pbar.finish()
......
......@@ -30,7 +30,6 @@ How to import
"""
from __future__ import print_function
import numpy
import spam.helpers
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment