ruby-units
ruby-units copied to clipboard
false equivalence between counting units
At the moment, counting units appear to be treated as interchangeable.
Unit.new('3 dB') == Unit.new('3 sr') # => true
Unit.new('3 sr') == Unit.new('3 nt') # => true
Unit.new('3 nt') == Unit.new('3 bp') # => true
Unit.new('3 bp') == Unit.new('3 molecule') # => true
Unit.new('3 molecule') == Unit.new('3 each') # => true
Unit.new('3 each') == Unit.new('3') # => true
This is an interesting one because under the covers each of these units is represented as the same 'kind'. Equivalence checks to see if the scalars and the kind match up so that different expressions for the same thing will be correctly identified as equal. It seems in the case of counting units it should also be checking for the equivalence of the unit name so that:
Unit.new('3 dB') == Unit.new('3 sr') # => false
I'll have to think about the implications of that one...