'<' not supported between instances of 'numpy.ndarray' and 'str'

2.2k views Asked by At

im doing a project about temperature and humidify control system. Im using skfuzzy as tool. I met some errors, after i try to edit with my own preference.

fanspeed = ctrl.ControlSystemSimulation(fanspeed_ctrl)

fanspeed.input['temperature'] = 40
fanspeed.input['humidify'] = 10

fanspeed.compute()
fanspeed.output['fan']
fan.view(sim=fanspeed)
print("Fan speed =",fanspeed.output['fan'])

Code above is working well but when i want it to accept user input instead of put the input in the code, so i try to change like this

fanspeed = ctrl.ControlSystemSimulation(fanspeed_ctrl)

temp = input("temp=")
hum = input("hum=")
fanspeed.input['temperature'] = temp
fanspeed.input['humidify'] = hum
fanspeed.compute()
fanspeed.output['fan']
fan.view(sim=fanspeed)
print("Fan speed =",fanspeed.output['fan'])

Anyone can give some advice will be nice :D Thanksssss

2

There are 2 answers

1
Tamir On BEST ANSWER

User input is str type. use temp = int(input("temp=")) and hum = int(input("hum="))

0
basilisk On
temp = int(input("temp="))
hum = int(input("hum="))
fanspeed.input['temperature'] = temp
fanspeed.input['humidify'] = hum
fanspeed.compute()
fanspeed.output['fan']
fan.view(sim=fanspeed)
print("Fan speed =",fanspeed.output['fan'])

The input function returns a string. What you need is an int. That's why the first example is working since you are assigning an int to the temp and hum variables and the second doesn't because you are assigning a str to it.