ladybug-tools / honeybee-core

:honeybee: honeybee core library
https://www.ladybug.tools/honeybee-core/docs/
GNU Affero General Public License v3.0
17 stars 15 forks source link

Bug in tuple_with_length #418

Closed devangcx closed 3 years ago

devangcx commented 3 years ago

Hi @chriswmackey,

I believe we need better type checking here

a = (255.12, 255, 255)
b = tuple_with_length(a, length=3, item_type=int)
print(b)

The above will print (255, 255, 255)

Here, I would expect an error to be thrown.

I am happy to send a PR if you agree that this needs to be fixed.

chriswmackey commented 3 years ago

Hey @devngc ,

This is not a bug but is the intended behavior and all of the typing functions do type casting like this. There are a lot of places where we rely on this type casing to convert from string to float, for example. So I don't agree with changing this function. If you really need an assert statement to make sure an input is of a particular data type, you should add it in whatever place you need such strict type checking .