seantronsen / pvt

GNU General Public License v3.0
0 stars 0 forks source link

Trackbars should accept real numbers, not just ints #34

Closed ghoulapool closed 5 months ago

ghoulapool commented 5 months ago

for example:

trackbar_omega_m = ParameterTrackbar("omega_m", 0.12, 0.155, init=0.1335)
trackbar_omega_b = ParameterTrackbar("omega_b", 0.0215, 0.0235, init=0.02258)
trackbar_sigma_8 = ParameterTrackbar("sigma_8", 0.7, 0.9, init=0.8)
trackbar_h = ParameterTrackbar("h", 0.55, 0.85, init=0.71)
trackbar_n_s = ParameterTrackbar("n_s", 0.85, 1.05, init=0.963)
trackbar_w_0 = ParameterTrackbar("w_0", -1.3, -0.7, init=-1.0)
trackbar_w_a = ParameterTrackbar("f", 0.0, 1.29, init=0.3)
trackbar_omega_nu = ParameterTrackbar("omega_nu", 0.0, 0.01, init=0.0)
trackbar_z = ParameterTrackbar("z", 0.0, 2.02, init=0.75)
seantronsen commented 5 months ago

Issue resolved as of: e1cf698

The new implementation for trackbar keeps track of an ndarray under the hood containing the range of values specified by start, stop, etc. The ndarray is created using np.arange, but the result does include the end of the range.

That is:

start = 0, 
stop = 20, 
step = 1, 

will result in the allocated range containing:

[0, 1, 2, ..., 20]

It should "just work" meaning if you use ints, the trackbar will spit out integer values and if any of the parameters are floats (except for init), then the trackbar will use floating point values.

NOTE: The default step size for the trackbar is still set as an integer with value = 1. If you're working with much smaller numbers like in the output shown in the first comment, you'll need to set an expected step size.

The demo has been updated to use the newer implementation and has some good examples. One is shown below: image

Closing.