Repository: openmm/openmm — pull request #4767 (cpp)
Title: Cleaner printing of units

This changes the default string representation of Quantities to print values with units in a simpler form.  With the current code:

```python
>>> 1.5*nanometers
Quantity(value=1.5, unit=nanometer)
```

With this PR:

```python
>>> 1.5*nanometers
1.5 nm
```

Resolved issues:
title: Cleaner printing of units
body: The current string representation of quantities in the library is verbose and not user-friendly. When a quantity is printed, it displays the value and unit in a detailed format, such as `Quantity(value=1.5, unit=nanometer)`. This format is unnecessarily complex and can make the output harder to read, especially when working with a large number of quantities.

The expected behavior is for quantities to be displayed in a cleaner and more concise format, showing only the numeric value followed by the unit symbol. For example, `1.5*nanometers` should be represented as `1.5 nm`. This would improve readability and make the output more intuitive for users.

## IMPORTANT INSTRUCTIONS

1. If you edit a python file, you MUST run 'make PythonInstall' inside the build directory
2. If you edit a c++ file, you MUST run 'make -j4 && make install" inside the build directory

Hints:

Fix patch:
diff --git a/wrappers/python/openmm/unit/quantity.py b/wrappers/python/openmm/unit/quantity.py
index d93283c7f9..0559c145cd 100644
--- a/wrappers/python/openmm/unit/quantity.py
+++ b/wrappers/python/openmm/unit/quantity.py
@@ -215,8 +215,7 @@ def __str__(self):
     def __repr__(self):
         """
         """
-        return (Quantity.__name__ + '(value=' + repr(self._value) + ', unit=' +
-                str(self.unit) + ')')
+        return str(self)
 
     def format(self, format_spec):
         return format_spec % self._value + ' ' + str(self.unit.get_symbol())


Test patch:
diff --git a/wrappers/python/tests/TestUnits.py b/wrappers/python/tests/TestUnits.py
index 5bbda4fb66..9c7712db8d 100644
--- a/wrappers/python/tests/TestUnits.py
+++ b/wrappers/python/tests/TestUnits.py
@@ -630,7 +630,7 @@ def testMisc(self):
         """ Miscellaneous tests for the unit package """
         self.assertTrue(u.meter is not None)
         self.assertFalse(u.meter is None)
-        self.assertEqual(repr(1.2*u.meters), 'Quantity(value=1.2, unit=meter)')
+        self.assertEqual(repr(1.2*u.meters), '1.2 m')
         class Foo(object):
             def bar(self):
                 return 'bar'