Skip to content

Latest commit

 

History

History
250 lines (241 loc) · 11.2 KB

changelog.org

File metadata and controls

250 lines (241 loc) · 11.2 KB

v0.4.3

  • add Dalton as a unit
  • add some more explanations for predefined constants

v0.4.2

  • minor fix to to such that we use exactly the type as given by the user, instead of yCT.toNimType(). This is to guarantee the property x.to(T) is T always holds.

v0.4.1

  • fix issue #48 where the unit parsing logic accepted invalid SI prefixes and thus code like foo.toMeter was valid (and looked like sensible code)

v0.4.0

  • add unit of Barn
  • BREAKING: rename short form of Gauss to gauss. Single capital G is too brittle combined with Giga prefix
  • improve printed unit names in error messages
  • add hbar as a constant
  • add note about natural unit convention used

v0.3.10

  • fix for nnkPostfix nodes in macro logic

v0.3.9

  • do not cache names of units anymore. Improves performance by 50% on files with many units (i.e. tests/tunchained.nim)!

v0.3.8

  • add some more astronomical units:
    • AstronomicalUnit, AU
    • LightYear, ly
    • Parsec, parsec (not pc due to pico coulomb)
  • add degree related units:
    • ArcMinute, arcmin
    • ArcSecond, arcsec
  • BREAKING: Change definition of 1 year from 365 days to 365.25 days (1 Julian year), matching definition of a light year. Otherwise they would disagree if computed “by hand” using our units. More precise, but of course highly dependent on your calendar / definitions -> For these time units it would probably be best to have different sets of units / unit systems, i.e. GregorianYear etc. Anyone dealing with time units should be aware that these things are tricky and best be dealt with given their specific application!

v0.3.7

  • add the unit Erg commonly used in astronomy
  • improve type extraction for element access from sequences with types & in particular sequences whose types have been defined by a mapIt call
  • fix extra colon in unit parsing (PR #41)

v0.3.6

  • add Torr as a unit of pressure
  • fixes a regression when parsing units with unicode runes (μ)
  • add submodule to help with parsing units in cligen program arguments

v0.3.5

  • fix parsing units possibly returning uninitialized UnitProduct (in particular when dealing with type aliases of UnitLess)

v0.3.4

  • fixes an issue with type aliases where a short name was turned into a long name that was no undefined, due to how we simplify the units, Works around the following:
    defUnit(ft²•ft⁻³)
    let x = 1.m⁻¹
    check x.to(ft²•ft⁻³) == 0.3048.ft⁻¹
    check x.to(ft²•ft⁻³) == 0.3048.ft²•ft⁻³
        

    now producing problems as we emit the long form of user given types later. Those were not defined, because we only define long versions of the reduced version, i.e. Foot⁻¹.

v0.3.3

  • emit long type names in to after all, due to issue with min (see #37 and #35). This is not a problem anymore, due to fully aliasing long and short names
  • works around a weird issue related to UnitTable where looking up a UnitProduct of a long name can sometimes return empty data. The key is being “replaced” by data that is essentially a UnitProduct with a not initialized DefinedUnit.

v0.3.2

  • add FloatBytes intdefine variable, which allows to change the underlying float type used at CT using -d:FloatBytes=4. Note: it might be advisable to also change the precision used to compare two units using -d:UnitCompareEpsilon= and setting it to some smaller value. Default is 8 corresponding to an epsilon of 1e-8. Further, using float32 can be problematic if used in combination with very low / very high SI prefixes due to the lower precision available.

v0.3.1

  • add new SI prefixes defined in November 2022: https://www.bipm.org/documents/20126/77765681/Resolutions-2022.pdf/281f3160-fc56-3e63-dbf7-77b76500990f
  • add “unit typedesc math” helper module, which defines procedures working with typedescs, so that the sometimes common approach:
    let x = 1 * kg * m / s^2
    doAssert x == 1.kg•m•s⁻²
    let y = 1.kg * m^2 / s^2
    doAssert y == 1.kg•m²•s⁻²
    let z = 1.m^2
    doAssert z == 1.m²
        

    just works.

  • fixes an issue with concept quantities where they would not match, due to wrong ordering in quantity comparison
  • change default generated definitions of units: Instead of generating the quantity types first and then all units, we now generate all units first as based on distinct quantities. Then for compound units we define all versions of base types as aliases to the unit name. That way we give the compound unit name “priority” in the eyes of the Nim compiler.
  • add caching of user defined units (string representation and internal representation) for minor performance improvements and keeping the user desired string representation around.
  • rewrite unit parser for significant performance improvements
  • change precedence of units again, so that fundamental compound units are preferred over base units. Means we write N•m instead of m•N.
  • make `$`, `pretty` macros to avoid Nim compiler eating alias names: The issue with the recent changes in `defUnit` to add more aliases for a better user experience is that generics tend to eat aliases. In a generic setting the Nim compiler will often only give us the first non aliased name. This is pretty annoying, as it then often gives us type names different from what the user intended. This gets around it, as we now perform the logic in place. NOTE: Keep in mind that typeof has the same issue as generics. The type name you see will be the first non alias name! As such avoid it for most things (only use for is calls)
  • also turn to into a macro for the same reason as $: Also here the issue is the same. As a generic we lose access to the real type of the symbol :(.

    Note that this may make toDef partially unnecessary. We’ll see how this works out.

    Also note that this breaks to in context of locally defined units combined with generics, as the macro for defUnit won’t be evaluated before and thus to won’t know the type.

    However, this is actually a lesser problem now, because we generate more aliases so the need for to has drastically gone down.

  • simplify dimensional analysis by adding a “fixed size” type QuantityPowerArray and giving each Quantity a unique ID
  • add ID fields for units to uniquely identify a unit based on that
  • rewrite simplify procedure for better performance
  • add unitOf, quantityOf return string representations of the unit / quantity of a given unitful variable.
  • toBaseUnits performs a conversion of the given unit to a combination of base units.

v0.3.0

  • concepts for each quantity to match different units of same quantity in procedure calls!
  • < for CT units now sorts positive powers before negative, this can be a breaking change
  • in `.` define the resulting type based on what’s given, not simplified, this can be a breaking change
  • add toDef to combine the usage of defUnit with to (this can be problematic, see docstring)
  • clean up defUnit and also always generate the short name version of a given unit
  • update README

v0.2.5

  • improve `^` handling for static integers (powers smaller 2 now supported as well as negative powers)
  • allow to print unit names without unicode half width space and no unicode symbols in unit names, if compiled with `-d:noUnicode`.
  • BREAKING: changes the default behavior of printing unitful variables from long format to short format!
    • to change the behavior you can either call pretty manually and hand short = false or compile with -d:ShortFormat=false.

v0.2.4

  • fix regression #29, multiplication / division between base and derived units (e.g. SI and an imperial) did not convert, even if they shared a common quantity

v0.2.3

  • fix resolving ntyGenericInst (which also effectively handles ntySequence it seems)
  • add G_Newton constant
  • add AreaDensity quantity

v0.2.2

  • fix to to explicitly only work with SomeUnit types

v0.2.1

  • fix underlying issue of #5, the loss of type information when using unitful const variables in unit math. The issue was our isUnitLessNumber check, as for const variables with numbers their node kind is still nnkFloatLit. The type needs to be looked at instead.
  • bump Nim version requirement to 1.6 to reflect the real version we support

v0.2.0

  • replaces definition of quantities and units by a fully declarative setup, which allows for much easier definition of custom unit systems, see PR #24 for more details
  • also see examples/custom_unit_system.nim for a (admittedly ridiculous) example of defining a custom unit system

v0.1.10

  • defUnits now has an export option to define a unit that is exported (therefore this defUnit can only be used at top level!)
  • add Gauss as a unit
  • allow conversion of Kelvin to natural units
  • allow units with `·` instead of `•` Note: this is only for units that user hands and constructs themselves. Predefined units or those auto generated when by `*` and similar still concat units using `•`. So YMMV and all that, but it opens up the possibility of being more flexible in the future.
  • add constant m_u, defined by M_u / N_A
  • rename Boltzmann constant from k to k_B
  • add pretty for units that allows a short parameter. That way the unit will be string converted to a name with the short unit naming, i.e. m•s⁻¹ instead of Meter•Second⁻¹. For now the default will remain the long version, but that may change in the future.

v0.1.9

  • add sqrt for units that are a perfect square
  • add abs for units
  • add +=, *=, … where they make sense (e.g. only same units for += and only with scalars for *=
  • add unary -
  • add hash for units
  • rename toFloat converters to a name less likely to conflict with other things (toRawFloat)
  • replace basic SI unit generation by a macro call (defineUnits)
  • change getUnitTypeImpl logic by using typeKind

v0.1.8

  • fix generation of SI prefixes if exclude is used. Previously mapping of short to long prefixes was broken if exclude was used.
  • fix math of compound units that involved conversions SI prefixes and conversions to base units (i.e. Tesla to kg•s⁻²•A⁻¹) by adding a global SI prefix factor field to CTCompoundUnit
  • reorder ukDegree in UnitKind enum

v0.1.7

  • emit SI prefixed versions of Bq

v0.1.6

  • add Becquerel as a unit for activity

v0.1.5

  • fix issue #16, division of compound units works correctly now
  • add Planck constant as hp and Boltzmann constant as k

v0.1.4

  • fix issue #13, conversion of degrees and radians not possible with to

v0.1.3

  • fix ordering of internal compile time units
  • make radian and steradian distinct meter based units to avoid conversion to a meter based representation when doing additive maths with them

v0.1.2

  • fix == macro for same types of different names

v0.1.1

  • fix bug causing “Pound-force” parsing to fail

v0.1.0

  • support for all SI base units and most compound SI units
  • experimental SI unit support for converting SI units to natural units according to HEP Lorentz-Heaviside convention
  • add imperial units: yard, foot, ounce, slug, lbf, acre