ruby-units icon indicating copy to clipboard operation
ruby-units copied to clipboard

false equivalence between counting units

Open hynkle opened this issue 12 years ago • 1 comments

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

hynkle avatar Mar 21 '13 19:03 hynkle

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...

olbrich avatar Mar 23 '13 13:03 olbrich