ghollisjr / cl-ana

Free (GPL) Common Lisp data analysis library with emphasis on modularity and conceptual clarity.
GNU General Public License v3.0
197 stars 18 forks source link

Minor bug patch in unit multiplication #15

Closed djeis97 closed 8 years ago

djeis97 commented 8 years ago

Unit multiplication has a bug where it will sometimes return a list containing one unit without an exponent. This confuses other parts of the quantity library, so this patch adds a check which unwraps the unneeded list.

Test: (unit-mult '((:meter 2)) '((:meter -1))) produces '(:meter) instead of just :meter, creating quantities which break when used in later calculations.

This was an odd one to debug, as the quantity printer is already well prepared for printing lists of quantities, so I could only see the problem by inspecting the actual quantity objects.

ghollisjr commented 8 years ago

Thanks for the fix!