-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suppress unit printing and parsing for Dimensionless #12
Comments
I believe the word "unit" (that gets printed under some circumstances) comes from quantity/Quantity.java line 26. |
The problem is that in the current setup, a unit's display string cannot have a length of 0. I have to allow that first before I can see whether all methods of the |
probably, also the |
A unit of "1" is not totally bad. But a unit named ""unit"" is wrong. The evaluator (under development as part of djutils-eval) evaluates "PI()" to "3.14159265 unit" but "PI()/PI()" to "1.00000000 1". |
A unit's name and id can now be blank, as long as the SI units show that the unit is dimensionless, and the scale is the Throw.when(
builder.getId().length() == 0
&& !(builder.getSiPrefixes().equals(SIPrefixes.NONE)
&& builder.getScale().equals(IdentityScale.SCALE)),
UnitRuntimeException.class, "Constructing unit %s: id.length cannot be 0", cName); and Throw.when(
builder.getName().length() == 0
&& !(builder.getSiPrefixes().equals(SIPrefixes.NONE)
&& builder.getScale().equals(IdentityScale.SCALE)),
UnitRuntimeException.class, "Constructing unit %s.%s: name.length cannot be 0", cName, unitId); |
This can be done as long as the SI units show that the unit is dimensionless (SIPrefixes.NONE), and the scale is the IdentityScale
Handled with ##IF - ##ENDIF tags. The Dimensionless of and valueOf functions relate to averbraeck/djunits#12
With new of() and valueOf() functions that have been generated by the latest version of the djunits-generator project.
The |
For the handling of a dimensionless |
The |
Things are somewhat improved but there are still some inconsistencies. To reproduce the problem run: In the first case the division is carried out by Dimensionless.java(391) which simple sets the target unit to DimensionlessUnit.SI By the way: DoubleScalarRel.java(100) is a divide method that returns SIScalar, but the javadoc says that it returns DoubleScalar<?>. |
Issue #14 has taken care of the "1" that is not printed anymore. |
Issue #14 is now (almost) completed, which should solve the remaining problems of this issue, so I close it again. |
The
Dimensionless
scalar, vector and matrix print a unit calledunit
under certain circumstances, and1
as a unit under other circumstances.unit
is not a sensible indication of the unit for a dimensionless number.1
is not a valid SI-unit. Probably the best solution is to completely suppress the unit printing and parsing for theDimensionless
scalar, vector and matrix.The text was updated successfully, but these errors were encountered: