Skip to content

Commit

Permalink
Merge pull request #196 from connorferster/fix/label_text_cannot_be_r…
Browse files Browse the repository at this point in the history
…ounded

Added check and conversion for non-numerical data coming in to sig_fig_round
  • Loading branch information
JWock82 committed May 7, 2024
2 parents 0e63ffc + ab93884 commit bce038e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions PyNite/Rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,13 @@ def _PrepContour(model, stress_type='Mx', combo_name='Combo 1'):
node.contour = sum(node.contour)/len(node.contour)

def sig_fig_round(number, sig_figs):
# Check for strings or other convertible data types
if not isinstance(number, (float, int)):
try:
number = float(number)
except:
raise ValueError(f"{number} is not a number. Ensure that all labels are numeric.")

if number == 0:
return 0

Expand Down

0 comments on commit bce038e

Please sign in to comment.