chore(python): remove dead code - sphere - GPU-based 3D discrete element method algorithm with optional fluid coupling
HTML git clone git://src.adamsgaard.dk/sphere
DIR Log
DIR Files
DIR Refs
DIR LICENSE
---
DIR commit bfb8577a44e6a85147e7ff4bab2b3bbb580c55d4
DIR parent 6c9f4c262c98d09947e6c8df549c1fc5ae4d8db2
HTML Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Sun, 5 Jul 2026 21:50:53 +0200
chore(python): remove dead code
Drop commented-out debug prints, fix a Python-2-only pickle call in
visualize(), and remove unreachable returns after raise in pytestutils.
Diffstat:
M python/sphere.py | 10 +---------
M tests/pytestutils.py | 5 +----
2 files changed, 2 insertions(+), 13 deletions(-)
---
DIR diff --git a/python/sphere.py b/python/sphere.py
@@ -662,7 +662,6 @@ class sim:
print('p_f')
return False
#elif self.phi != other.phi).any():
- #print('phi')
#return False # Porosities not initialized correctly
elif (self.dphi != other.dphi).any():
print('d_phi')
@@ -5590,7 +5589,6 @@ class sim:
else:
lw = (f_n - f_n_lim)/(f_n_max - f_n_lim)*lw_max
- #print lw
plt.plot([x1, x2], [z1, z2], '-k', linewidth=lw)
axfc1 = plt.gca()
@@ -6624,10 +6622,6 @@ class sim:
volumetric_strain[i] = (vol0-vol)/vol0
deviatoric_stress[i] = sigma1 / sb.w_sigma0[1]
- #print(lastfile)
- #print(axial_strain)
- #print(deviatoric_stress)
- #print(volumetric_strain)
# Plotting
if outformat != 'txt':
@@ -6788,7 +6782,6 @@ class sim:
else:
# Write values to textfile
filename = "shear-stresses-{0}.txt".format(self.sid)
- #print("Writing stress data to " + filename)
fh = None
try:
fh = open(filename, "w")
@@ -7137,7 +7130,6 @@ class sim:
i_min = 0
i_max = sb.status()
# use largest difference in p from 0 as +/- limit on colormap
- #print i_min, i_max
p_ext = numpy.max(numpy.abs(pres))
if sb.wmode[0] == 3:
@@ -7284,7 +7276,7 @@ class sim:
else:
filename = '{0}-{1}.{2}'.format(self.sid, method, outformat)
if pickle:
- pl.dump(fig, file(filename + '.pickle', 'w'))
+ pl.dump(fig, open(filename + '.pickle', 'wb'))
# Optional save of figure
if outformat != 'txt':
DIR diff --git a/tests/pytestutils.py b/tests/pytestutils.py
@@ -2,6 +2,7 @@
from sphere import *
from highlighttext import highlight
+import numpy
import subprocess
import sys
@@ -25,7 +26,6 @@ def compare(first, second, string):
else:
print(string + failed() + ' (' + str(returnvalue) + ')')
raise Exception("Failed")
- return(returnvalue)
def compareFloats(first, second, string, tolerance=1e-3):
#if abs(first-second) < tolerance:
@@ -38,7 +38,6 @@ def compareFloats(first, second, string, tolerance=1e-3):
print("Abs. difference: " + str(second-first))
print("Rel. difference: " + str(abs((first-second)/first)))
raise Exception("Failed")
- return(1)
def compareNumpyArrays(first, second, string):
if ((first == second).all()):
@@ -46,7 +45,6 @@ def compareNumpyArrays(first, second, string):
else :
print(string + failed())
raise Exception("Failed")
- return(1)
def compareNumpyArraysClose(first, second, string, tolerance=1e-5):
if (numpy.allclose(first, second, atol=tolerance)):
@@ -60,4 +58,3 @@ def compareNumpyArraysClose(first, second, string, tolerance=1e-5):
print(numpy.mean(second))
print(numpy.max(second))
raise Exception("Failed")
- return(1)