MCPcopy Create free account
hub / github.com/CoolProp/CoolProp / _plotRound

Method _plotRound

wrappers/Python/CoolProp/Plots/Plots.py:90–115  ·  view source on GitHub ↗

A function round an array-like object while maintaining the amount of entries. This is needed for the isolines since we want the labels to look pretty (=rounding), but we do not know the spacing of the lines. A fixed number of digits after rounding might lead

(self, values)

Source from the content-addressed store, hash-verified

88 super(PropertyPlot, self).savefig(*args, **kwargs)
89
90 def _plotRound(self, values):
91 """
92 A function round an array-like object while maintaining the
93 amount of entries. This is needed for the isolines since we
94 want the labels to look pretty (=rounding), but we do not
95 know the spacing of the lines. A fixed number of digits after
96 rounding might lead to reduced array size.
97 """
98 inVal = np.unique(np.sort(np.array(values)))
99 output = inVal[1:] * 0.0
100 digits = -1
101 limit = 10
102 lim = inVal * 0.0 + 10
103 # remove less from the numbers until same length,
104 # more than 10 significant digits does not really
105 # make sense, does it?
106 while len(inVal) > len(output) and digits < limit:
107 digits += 1
108 val = (np.around(np.log10(np.abs(inVal))) * -1) + digits + 1
109 val = np.where(val < lim, val, lim)
110 val = np.where(val > -lim, val, -lim)
111 output = np.zeros(inVal.shape)
112 for i in range(len(inVal)):
113 output[i] = np.around(inVal[i], decimals=int(val[i]))
114 output = np.unique(output)
115 return output
116
117 def calc_isolines(self, iso_type=None, iso_range=None, num=15, rounding=False, points=250):
118 """Calculate lines with constant values of type 'iso_type' in terms of x and y as

Callers 1

calc_isolinesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected