Skip to content

Commit

Permalink
update docs and code in preparation for a release (#230)
Browse files Browse the repository at this point in the history
* update docs and code in preparation for a release

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
phlptp and pre-commit-ci[bot] authored May 15, 2022
1 parent 777c844 commit eb8d59b
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 39 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,20 @@ jobs:
cmake-version: "3.20"
if: success() || failure()

- name: Check CMake 3.21 (full)
- name: Check CMake 3.21
uses: ./.github/actions/quick_cmake
with:
cmake-version: "3.21"
if: success() || failure()

- name: Check CMake 3.22 (full)
- name: Check CMake 3.22
uses: ./.github/actions/quick_cmake
with:
cmake-version: "3.22"
if: success() || failure()

- name: Check CMake 3.23 (full)
uses: ./.github/actions/quick_cmake
with:
cmake-version: "3.23"
if: success() || failure()
51 changes: 43 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,56 @@ All notable changes to this project after the 0.2.0 release will be documented i
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.6.0][] ~ 2020-09-30
## [0.6.0][] ~ 2022-05-16

This release has a number of fixes for specific unit strings, adds some other units and a new unit_conversion_maps structure to reduce stack usage.

### Changed

- Convert default branch to "main"
- The string maps are new defined in a constexpr array in `units_conversion_maps.hpp` this reduces the stack usage significantly and clears up some warnings about that on some compilers [#217][],[#226][]
- The country specific codes for China and Canada were changed from "ch" and `can` to `cn` and `ca` to match country top level domains [#229][]

### Fixed

- The "hartree" string produced an incorrect value
- The "hartree" string produced an incorrect value [#163][]
- Fixed an issue with inverse multipliers for inverse conversions [#166][]
- changed the string conversions to better align with SI recommendations [#173][]
- Fix an issue with the string "0.2" [#188][]
- Fix asterisk operator typo [#194][]
- Update the docker images to use more recent base images [#206][],[#212][]
- User defined units were not being used in the string conversion operations properly [#213][]
- Update third party library links [#216][]
- Clean up some `if constexpr` warnings on some platforms [#227][]
- Fix an issue of misinterpreting short strings with spaces such as `kg m` [#224][]

### Added

- Added a series of constants to make the available constants match the Nist [Common Constants](https://physics.nist.gov/cgi-bin/cuu/Category?view=html&Frequently+used+constants.x=87&Frequently+used+constants.y=18) list
- added "Eh" as a valid string value for "hartree"

### Removed

## [0.5.0][] - 2020-08-17
- Added a series of constants to make the available constants match the Nist [Common Constants](https://physics.nist.gov/cgi-bin/cuu/Category?view=html&Frequently+used+constants.x=87&Frequently+used+constants.y=18) list [#163][]
- added "Eh" as a valid string value for "hartree" [#163][]
- Added support for larger power factors in units when using larger base [#184][]
- Added support for some climate related units [#210][],[#179][]
- Added mass to weight conversions [#229][]
- added domains to allow some domain specific units that might mean different things in different contexts [#173][]

[#226]: https://github.com/LLNL/units/pull/226
[#166]: https://github.com/LLNL/units/pull/166
[#188]: https://github.com/LLNL/units/pull/188
[#229]: https://github.com/LLNL/units/pull/229
[#173]: https://github.com/LLNL/units/pull/173
[#210]: https://github.com/LLNL/units/pull/210
[#179]: https://github.com/LLNL/units/pull/179
[#184]: https://github.com/LLNL/units/pull/184
[#163]: https://github.com/LLNL/units/pull/163
[#224]: https://github.com/LLNL/units/pull/224
[#216]: https://github.com/LLNL/units/pull/216
[#227]: https://github.com/LLNL/units/pull/227
[#213]: https://github.com/LLNL/units/pull/213
[#212]: https://github.com/LLNL/units/pull/212
[#206]: https://github.com/LLNL/units/pull/206
[#194]: https://github.com/LLNL/units/pull/194

## [0.5.0][] - 2021-08-17

This release includes some changes to the CMake builds and Targets. Also includes support for 64 bit base types for units with expanded power support, and support for a custom namespace for better integration with other applications. And additional units for natural gas and particle physics.

Expand Down Expand Up @@ -205,3 +239,4 @@ Continued work on cleaning up the library and starting to add main documentation
[0.4.0]: https://github.com/LLNL/units/releases/tag/v0.4.0
[0.3.0]: https://github.com/LLNL/units/releases/tag/v0.3.0
[0.2.0]: https://github.com/LLNL/units/releases/tag/v0.2.0
[0.6.0]: https://github.com/LLNL/units/releases/tag/v0.6.0
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

cmake_minimum_required(VERSION 3.0)

# Make sure users don't get warnings on a tested (3.0 to 3.22) version of CMake. For
# Make sure users don't get warnings on a tested (3.0 to 3.23) version of CMake. For
# most of the policies, the new version is better (hence the change). We don't use the
# 3.0...3.17 syntax because of a bug in an older MSVC's built-in and modified CMake 3.11
if(${CMAKE_VERSION} VERSION_LESS 3.22)
if(${CMAKE_VERSION} VERSION_LESS 3.23)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
else()
cmake_policy(VERSION 3.22)
cmake_policy(VERSION 3.23)
endif()

project(
Expand Down
8 changes: 5 additions & 3 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
## Other

- [Corey McNeish](https://github.com/mcneish1)
- [Greg Sjaardema](https://github.com/gsjaardema) -Documentation updates
- [Greg Sjaardema](https://github.com/gsjaardema) - Documentation updates
- [JensMunkHansen](https://github.com/JensMunkHansen)
- [Simon Heybrock](https://github.com/SimonHeybrock) -Doc updates and help supporting 64 bit unit base types, some additional constants and suggestions related to particle physics
- [Simon Heybrock](https://github.com/SimonHeybrock) - Doc updates and help supporting 64 bit unit base types, some additional constants and suggestions related to particle physics
- [Kerim371](https://github.com/SimonHeybrock) - CMake builds for the shared library version
- [Owen Arnold](https://github.com/OwenArnold) -Documentation
- [Owen Arnold](https://github.com/OwenArnold) - Documentation
- [Peter Steneteg](https://github.com/petersteneteg)
- [Jan-Lukas Wynen](https://github.com/jl-wynen) - Support for multi-digit power strings

## Used Libraries or Code

Expand Down
4 changes: 2 additions & 2 deletions FuzzTargets/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM helics/buildenv:clang-builder8 as builder

# this is already in a workdir from the builder image
# modification date 2022-03-24
# modification date 2022-05-16

RUN git clone https://github.com/LLNL/units.git units

Expand All @@ -25,7 +25,7 @@ LABEL name="units.fuzzer"
LABEL description="Units library fuzzer"
LABEL vcs-ref=$GIT_COMMIT
LABEL vcs-url="https://github.com/LLNL/units"
LABEL version="0.5.1"
LABEL version="0.6.0"
VOLUME /fuzz

#ENV ASAN_OPTIONS='quarantine_size_mb=16:max_redzone=512:detect_leaks=0:max_malloc_fill_size=1024'
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

[What's new](./CHANGELOG.md)

_Some of the CMake target names have changed in the latest release, please update builds appropriately_

[Documentation](https://units.readthedocs.io/en/latest/)

A library that provides runtime unit values, instead of individual unit types, for the purposes of working with units of measurement at run time possibly from user input.
Expand Down Expand Up @@ -113,7 +111,7 @@ These libraries will work well if the number of units being dealt with is known
2. Performance is absolutely critical (many other libraries are zero runtime overhead)
3. You are only working with a small number of known units
4. You cannot use C++11 yet.
5. You need to operate on arbitrary or fractional powers of base units
5. You need to operate on arbitrary or general fractional powers of base units

## Types

Expand All @@ -126,7 +124,7 @@ There are only a few types in the library
- `precise_measurement` is similar to measurement except using a double for the quantity and a `precise_unit` as the units.
- `fixed_measurement` is a 16 byte type containing a double value along with a constant `unit` and mathematical operations can be performed on it usually producing a new `measurement`. The distinction between `fixed_measurement` and `measurement` is that the unit definition of `fixed_measurement` is constant and any assignments get automatically converted, `fixed_measurement`'s are implicitly convertible to a `measurement` of the same value type. fixed_measurement also support some operation with pure numbers by assuming a unit that are not allowed on regular measurement types.
- `fixed_precise_measurement` is similar to `fixed_measurement` except it uses `precise_unit` as a base and uses a double for the measurement instead of a template, except it is 24 bytes instead of 16.
- `uncertain_measurement` is similar to `measurement` except it uses a 32-bit float for the value and contains an uncertainty field which is also 32-bits. Mathematical operations on `uncertain_measurements` will propagate the uncertainty and convert it as necessary. The class also includes functions for simple-uncertainty propagation like `simple_subtract` which just sums the uncertainties. The sum-of-squares methods is used in the overloaded math operators. Mathematical operations are supported on the type and it interoperates with measurements.
- `uncertain_measurement` is similar to `measurement` except it uses a 32-bit float for the value and contains an uncertainty field which is also 32-bits. Mathematical operations on `uncertain_measurement`s will propagate the uncertainty and convert it as necessary. The class also includes functions for simple-uncertainty propagation like `simple_subtract` which just sums the uncertainties. The sum-of-squares methods is used in the overloaded math operators. Mathematical operations are supported on the type and it interoperates with measurements.

## Unit representation

Expand Down Expand Up @@ -177,7 +175,7 @@ There are two parts of the library a header only portion that can simply be copi

The second part is a few cpp files that can add some additional functionality. The primary additions from the cpp file are an ability to take roots of units and measurements and convert to and from strings. These files can be built as a standalone static library or included in the source code of whatever project want to use them. The code should build with an C++11 compiler. Most of the library is tagged with constexpr so can be run at compile time to link units that are known at compile time. Unit numerical conversions are not at compile time, so will have a run-time cost. A `quick_convert` function is available to do simple conversions. with a requirement that the units have the same base and not be an equation unit. The cpp code also includes some functions for commodities and will eventually have r20 and x12 conversions, though this is not complete yet.

It builds by default with the static library. Using `UNIT_BUILD_SHARED_LIBRARY` or `BUILD_SHARED_LIBS` will build the shared library instead. Either one can be used with CMake as units::units. The header only library target is also generated `units::header_only`. The shared/static library has a CMake target `units::units`.
It builds by default with the static library. Using `UNIT_BUILD_SHARED_LIBRARY` or `BUILD_SHARED_LIBS` will build the shared library instead. Either one can be used with CMake as `units::units`. The header only library target is also generated `units::header_only`. The shared/static library has a CMake target `units::units`.

## Try it out

Expand Down
4 changes: 4 additions & 0 deletions docs/user-guide/Physical_constants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ There are a few numbers that are used in the library and include definitions in
- `tau` (2.0*pi)
- `invalid_conversion` (NaN)
- `infinity`
- `standard_gravity` the numerical value of g0, earth standard gravity in m/s/sec
- `speed_of_light` The numerical value of the speed of light in m/s

The last two are used in several other units and some conversions so it seemed better to just define the numerical value and use that rather than use the same number in several places.

From Strings
-----------------
Expand Down
6 changes: 4 additions & 2 deletions units/unit_definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ namespace constants {
constexpr double invalid_conversion =
std::numeric_limits<double>::signaling_NaN();
constexpr double infinity = std::numeric_limits<double>::infinity();
constexpr double standard_gravity = 9.80665;
constexpr double standard_gravity = 9.80665; // in m/s/s
constexpr double speed_of_light = 299792458.0; // speed of light in m/s
} // namespace constants

/// basic commodity definitions
Expand Down Expand Up @@ -294,7 +295,8 @@ namespace precise {

/// Units from the cgs system
namespace cgs {
constexpr double c_const = 29979245800.0; // speed of light in cm/s
constexpr double c_const =
constants::speed_of_light * 100.0; // speed of light in cm/s
constexpr precise_unit erg(1e-7, J);
constexpr precise_unit dyn(1e-5, N);
constexpr precise_unit barye(0.1, Pa);
Expand Down
4 changes: 2 additions & 2 deletions units/units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2485,8 +2485,8 @@ static precise_unit
ckpair{"avoirdupois", "_av"},
ckpair{"Chinese", "_cn"},
ckpair{"chinese", "_cn"},
ckpair{"Canadian", "_can"},
ckpair{"canadian", "_can"},
ckpair{"Canadian", "_ca"},
ckpair{"canadian", "_ca"},
ckpair{"survey", "_us"},
ckpair{"tropical", "_t"},
ckpair{"British", "_br"},
Expand Down
4 changes: 3 additions & 1 deletion units/units.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2036,7 +2036,9 @@ namespace constants {
precise_unit(
detail::unit_data(3, -1, -2, 0, 0, 0, 0, 0, 0, 0, 0U, 0U, 0U, 0U)));
/// Speed of light
constexpr precise_measurement c{299792458.0, precise::m / precise::s};
constexpr precise_measurement c{
constants::speed_of_light,
precise::m / precise::s};
/// Elementary Charge (2019 redefinition)
constexpr precise_measurement e(1.602176634e-19, precise::C);
/// hyperfine structure transition frequency of the cesium-133 atom
Expand Down
16 changes: 8 additions & 8 deletions units/units_conversion_maps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2065,14 +2065,14 @@ UNITS_CPP14_CONSTEXPR_OBJECT std::array<
{"flbarrel", precise::us::flbarrel},
{"fluidbarrel", precise::us::flbarrel},
{"liquidbarrel", precise::us::flbarrel},
{"gal_can", precise::canada::gallon},
{"gallon_can", precise::canada::gallon},
{"tbsp_can", precise::canada::tbsp},
{"tsp_can", precise::canada::tsp},
{"tablespoon_can", precise::canada::tbsp},
{"teaspoon_can", precise::canada::tsp},
{"cup_can", precise::canada::cup},
{"traditional_cup_can", precise::canada::cup_trad},
{"gal_ca", precise::canada::gallon},
{"gallon_ca", precise::canada::gallon},
{"tbsp_ca", precise::canada::tbsp},
{"tsp_ca", precise::canada::tsp},
{"tablespoon_ca", precise::canada::tbsp},
{"teaspoon_ca", precise::canada::tsp},
{"cup_ca", precise::canada::cup},
{"traditional_cup_ca", precise::canada::cup_trad},
{"drum", precise::volume::drum},
{"gallon", precise::gal},
{"hogshead", precise::us::hogshead},
Expand Down
6 changes: 3 additions & 3 deletions webserver/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM helics/buildenv:gcc11-builder as builder

# modification date 2022-03-24
# modification date 2022-05-16

RUN git clone https://github.com/LLNL/units.git units

Expand All @@ -24,8 +24,8 @@ LABEL name="units.webserver"
LABEL description="Units library webserver"
LABEL vcs-ref=$GIT_COMMIT
LABEL vcs-url="https://github.com/LLNL/units"
LABEL version="0.5.1"
LABEL date="2022-03-24"
LABEL version="0.6.0"
LABEL date="2022-05-16"

VOLUME /weblog

Expand Down

0 comments on commit eb8d59b

Please sign in to comment.