hey assistent, I have this def constantfromdmax(dmax, starttime, endtime): num_steps =…
- User
hey assistent, I have this def constant_from_dmax(dmax, start_time, end_time): num_steps = FREQ * (end_time - start_time) x_values = np.linspace(start_time, end_time, num_steps) y_values = np.full(num_steps, dmax) return x_values, y_values where time_INFLEXION = 5 x_SPEED_OF_INFLEXION, y_SPEED_OF_INFLEXION = constant_from_dmax( DMAX, time_DMAX, time_INFLEXION ). for this function I also have an INFLEXIOn speed variable that has a slider. When for example when the inflexion is 10, I should have time of 5. but when is 20 I should have time of 2.5. The thing is ploting in secons seems hard, I can't figure out how to do it
- Assistant
It sounds like you're trying to plot a line or function that changes with respect to an "inflexion speed" variable such that the time it takes varies inversely with the inflexion speed. It looks like you want to plot this function over a time interval and handle it dynamically depending on the inflexion speed.
- User
doing so I get this File "C:\Users\p128223\OneDrive - Alliance\Bureau\workspace\one_pedal.py", line 15, in constant_from_dmax x_values = np.linspace(start_time, end_time, num_steps) File "C:\Users\p128223\OneDrive - Alliance\Bureau\workspace\paranghelia\lib\site-packages\numpy_core\function_base.py", line 127, in linspace num = operator.index(num) TypeError: 'float' object cannot be interpreted as an integer. I this meens I can't have 2.9 seconds. but this is what I need
- Assistant
The error you're encountering arises because
np.linspacerequires the number of samples (num_steps) to be an integer. This problem often occurs whenend_time - start_timeresults in a non-integer and is multiplied byFREQ, leading to a float.