Skip to content
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

✨ Added a function to round a number to n decimal places #189

Merged
merged 13 commits into from
Apr 19, 2023

Conversation

Drewniok
Copy link
Collaborator

@Drewniok Drewniok commented Apr 19, 2023

Description

This PR introduces a new function for rounding numbers of different types to n decimal places.

Checklist:

  • The pull request only contains commits that are related to it.
  • I have added appropriate tests and documentation.
  • I have made sure that all CI jobs on GitHub pass.
  • The pull request introduces no new warnings and follows the project's style guidelines.

dependabot bot and others added 8 commits April 2, 2023 15:38
Bumps [libs/Catch2](https://github.com/catchorg/Catch2) from `6783411` to `1f881ab`.
- [Release notes](https://github.com/catchorg/Catch2/releases)
- [Commits](catchorg/Catch2@6783411...1f881ab)

---
updated-dependencies:
- dependency-name: libs/Catch2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [libs/parallel-hashmap](https://github.com/greg7mdp/parallel-hashmap) from `7883cb6` to `d2bed96`.
- [Release notes](https://github.com/greg7mdp/parallel-hashmap/releases)
- [Commits](greg7mdp/parallel-hashmap@7883cb6...d2bed96)

---
updated-dependencies:
- dependency-name: libs/parallel-hashmap
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@Drewniok Drewniok requested a review from marcelwa April 19, 2023 09:01
@codecov
Copy link

codecov bot commented Apr 19, 2023

Codecov Report

Merging #189 (e5d75cc) into main (6d3bf1e) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #189      +/-   ##
==========================================
- Coverage   94.25%   94.24%   -0.02%     
==========================================
  Files          76       77       +1     
  Lines        7089     7091       +2     
==========================================
+ Hits         6682     6683       +1     
- Misses        407      408       +1     
Impacted Files Coverage Δ
...algorithms/simulation/sidb/energy_distribution.hpp 100.00% <100.00%> (ø)
include/fiction/utils/math_utils.hpp 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d3bf1e...e5d75cc. Read the comment docs.

Copy link
Collaborator

@marcelwa marcelwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a nice helper function. Many thanks! Just a couple requests.

Also, could you already make use of this function in all the places that it is intended for in this PR?

include/fiction/utils/round_n_decimal_places.hpp Outdated Show resolved Hide resolved
include/fiction/utils/round_n_decimal_places.hpp Outdated Show resolved Hide resolved
include/fiction/utils/round_n_decimal_places.hpp Outdated Show resolved Hide resolved
include/fiction/utils/round_n_decimal_places.hpp Outdated Show resolved Hide resolved
include/fiction/utils/round_n_decimal_places.hpp Outdated Show resolved Hide resolved
include/fiction/utils/round_n_decimal_places.hpp Outdated Show resolved Hide resolved
include/fiction/utils/round_n_decimal_places.hpp Outdated Show resolved Hide resolved
@marcelwa marcelwa added the enhancement New feature or request label Apr 19, 2023
@marcelwa marcelwa changed the title Function to round number to n decimal places. ✨ Added a function to round a number to n decimal places Apr 19, 2023
@Drewniok Drewniok requested a review from marcelwa April 19, 2023 12:09
@Drewniok Drewniok merged commit 329e749 into cda-tum:main Apr 19, 2023
Drewniok added a commit that referenced this pull request May 7, 2023
* ✨ header for temperature simulation

* ✨ header for temperature simulation

* ✅ occupation function with tests

* 🚧 "critical temperature function" is implemented. Test also added.

* 🚧 CT of "bestagon gates" can be simulated correctly

* ✅ tests updated

* ✅ tests updated

* ✅ tests updated

* 🎨 map replaced by vector

* 📝 docu for new functions

* 📝 docu for new functions

* 🎨 ClangFormat changes

Signed-off-by: ClangFormat <[email protected]>

* 🚀

* ⬆️ submodules upgraded

* 🎨 ClangFormat changes

Signed-off-by: ClangFormat <[email protected]>

* 🎨 small cahnges

* 🎨 ClangFormat changes

Signed-off-by: ClangFormat <[email protected]>

* 🎨 replaced std::rand(), caused problem at temperature implementation

* 🎨 small changes here and there

* 🎨 reformat code

* 🎨 ClangFormat changes

Signed-off-by: ClangFormat <[email protected]>

* 🎨 renaming function

* ✨ flag added to decide between gate and random layout

* ✨ flag added to decide between gate and random layout

* ✨ flag added to decide between gate and random layout

* ✨ min_energy added in occupation_probability.hpp

* 🎨 Reformatted and cleaned up code

* 🎨 ClangFormat changes

Signed-off-by: ClangFormat <[email protected]>

* 🎨 Slight revision for consistency

* 🎨 renaming

* ⬆️ Bump libs/Catch2 from `50bf00e` to `9a2a4ea` (#182)

* 🎨 reformat code

* redefinition of sidb_nm_position (#186)

* ⬆️ Bump libs/Catch2 from `6783411` to `1f881ab` (#27)

Bumps [libs/Catch2](https://github.com/catchorg/Catch2) from `6783411` to `1f881ab`.
- [Release notes](https://github.com/catchorg/Catch2/releases)
- [Commits](catchorg/Catch2@6783411...1f881ab)

---
updated-dependencies:
- dependency-name: libs/Catch2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump libs/parallel-hashmap from `7883cb6` to `d2bed96` (#33)

Bumps [libs/parallel-hashmap](https://github.com/greg7mdp/parallel-hashmap) from `7883cb6` to `d2bed96`.
- [Release notes](https://github.com/greg7mdp/parallel-hashmap/releases)
- [Commits](greg7mdp/parallel-hashmap@7883cb6...d2bed96)

---
updated-dependencies:
- dependency-name: libs/parallel-hashmap
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* 🎨 return value of ``sidb_nm_position`` changed from meter to nanometer for consistency.

* 🎨 renaming.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Drewniok <[email protected]>

* 👷 Use the GitHub token of the checked-out repo instead of the own for the `add-and-commit` action after clang-format has been run

* 🎨 Changed the unit of the lambda-tf physical parameter from meter to nanometer (#188)

* 🎨 Unit of `lambda_tf` is changed from meter to nanometer.

* 🎨 `epsilon_r` is unit-less.

* ✨ Added a function to round a number to `n` decimal places (#189)

* ✨ small function to round numbers to ``n`` decimal places.

* ✅ test added.

* 🎨 implemented Marcel's suggestions.

* 🎨 make use of new function in ``energy_distribution``.

* ✨ Added an SiDB simulation file writer (#176)

* ✨ Added a new unified return type for SiDB simulation

* ✨ Added a file writer for SQD simulation runs parsable by SiQAD

* 📝 Added and fixed docstrings

* 📝 Added RST documentation

* 📝 Removed superfluous newlines

* 🎨 Incorporated clang-tidy's recommendations

* 🎨 Rewrote `any_to_string` to be more performant and extensible

* 🐛 Replaced the usage of the custom charge to string function with the one provided by `sidb_charge_state.hpp`

* ✅ Added a test case for positive SiDBs

* ✅ Added test cases for `any_to_string`

* 🎨 ClangFormat changes

Signed-off-by: ClangFormat <[email protected]>

* 🐛 Added `inline` to `any_to_string` in order to avoid ODR problems

* ✅ Fixed the test case

* 🎨 ClangFormat changes

Signed-off-by: ClangFormat <[email protected]>

* 👽 Convert nm to Angstrom

* 👽 Round distances and energy values to 6 decimal points

* ✅ Added additional tests to cover more lines

* 🎨 ClangFormat changes

Signed-off-by: ClangFormat <[email protected]>

---------

Signed-off-by: ClangFormat <[email protected]>
Co-authored-by: ClangFormat <[email protected]>

* 🎨 larger architectural changes.

* 🎨 reformat code and documentation.

* 🎨 small changes in exhaustive_ground_state_simulation.hpp due to unit changes from ``main`` branch.

* 📝 added docu.

* ⬆️ Bump ZedThree/clang-tidy-review from 0.12.2 to 0.13.0 (#193)

* ⬆️ Bump libs/Catch2 from `9a2a4ea` to `10596b2` (#191)

Bumps [libs/Catch2](https://github.com/catchorg/Catch2) from `9a2a4ea` to `10596b2`.
- [Release notes](https://github.com/catchorg/Catch2/releases)
- [Commits](catchorg/Catch2@9a2a4ea...10596b2)

---
updated-dependencies:
- dependency-name: libs/Catch2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump libs/parallel-hashmap from `d2bed96` to `7807157` (#192)

Bumps [libs/parallel-hashmap](https://github.com/greg7mdp/parallel-hashmap) from `d2bed96` to `7807157`.
- [Release notes](https://github.com/greg7mdp/parallel-hashmap/releases)
- [Commits](greg7mdp/parallel-hashmap@d2bed96...7807157)

---
updated-dependencies:
- dependency-name: libs/parallel-hashmap
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ✅ Ensured a reproducible SiDB order for test reproducibility (#194)

* ✅ Ensured a reproducible SiDB order for test reproducibility

* 💚 Ordered surfaces as well

---------

Co-authored-by: Jan Drewniok <[email protected]>

* 🎨 ClangFormat changes

Signed-off-by: ClangFormat <[email protected]>

* ⬆️ Bump DoozyX/clang-format-lint-action from 0.15 to 0.16 (#196)

Bumps [DoozyX/clang-format-lint-action](https://github.com/DoozyX/clang-format-lint-action) from 0.15 to 0.16.
- [Release notes](https://github.com/DoozyX/clang-format-lint-action/releases)
- [Commits](DoozyX/clang-format-lint-action@v0.15...v0.16)

---
updated-dependencies:
- dependency-name: DoozyX/clang-format-lint-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* 🎨 changes after review.

* 🎨 ClangFormat changes

Signed-off-by: ClangFormat <[email protected]>

* 🎨 changes after review.

* 🎨 use data type for energy distribution.

* 🎨 additional ``else`` to try to fix windows build issue.

* ✨ Make ClangFormat aware of different line ending types and enforce `LF` (#177)

* 🎨 Added a flag to the ClangFormat config to enforce LF line endings (as of version 16)

* 🎨 Re-applied ClangFormat to the project

* ⬆️ Switched to ClangFormat 16

* 📝 add links for RST.

* 📝 add links for RST.

* 📝 add named anchor.

* 📝 use ``-`` instead of ``_``.

* 🐛 add missing ``$`` in docstring.

* 🎨 ClangFormat changes

Signed-off-by: ClangFormat <[email protected]>

* 🎨 copy enum class to try to solve window build issue.

* 🎨 tiny change in docu.

* 🎨 ClangFormat changes

Signed-off-by: ClangFormat <[email protected]>

* 🎨 ClangFormat changes

Signed-off-by: ClangFormat <[email protected]>

* 🔥 remove file from git.

* ✅ add additional test.

* 🐛 add ``recompute_energy`` and test which failed before.

* 🎨 change to scoped enumerator.

* 🎨 ClangFormat changes

Signed-off-by: ClangFormat <[email protected]>

* 🎨 use enum struct.

* 🔥 remove ``enum class``due to windows CI issue.

* 🎨 ClangFormat changes

Signed-off-by: ClangFormat <[email protected]>

* 🎨 replace reference.

* ✨ code to generate unique random layouts.

* ✨ Temperature-aware simulation can be conducted with ``exgs`` or ``quicksim``. All simulation engines use ``sidb_simulation_result`` now to collect results.

* 🎨 ClangFormat changes

Signed-off-by: ClangFormat <[email protected]>

* 🎨 rename struct member.

* 🎨 activate automatic state count detection.

* ⬆️ Bump libs/parallel-hashmap from `7807157` to `9f09034` (#199)

* 🎨 Ensured SiQAD compatibility of SiDB simulation result writer (#197)

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* 🎨 fix ``state count`` to three. Two is not supported by SiQAD yet.

* 🎨 reformat code.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Marcel Walter <[email protected]>

* 🎨 update after review (main change: replace stats_pointer as input for simulators).

* 🎨 ClangFormat changes

Signed-off-by: ClangFormat <[email protected]>

* 🎨 introduce impl_class for quickexact.

* 🎨 remove ``const``keyword.

* 🎨 add ``const``keyword.

* 🎨 split in several smaller functions.

* 🎨 rename some functions.

* 📝 add docu.

* ✨ automatic base number detection can be turned ``on`` and ``off``.

* 📝 add more documentation.

* 🔥 remove files to shift it to separate PR.

* 🎨 change order of ``const``keyword and type.

* 📝 add RST.

* 📝 add documentation.

* 💚 add ``const`` keyword.

* 🎨 smaller changes to try to fix test issue.

* ✅ small change to avoid windows issue.

* 📝 add documentation.

---------

Signed-off-by: ClangFormat <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Drewniok <[email protected]>
Co-authored-by: ClangFormat <[email protected]>
Co-authored-by: Marcel Walter <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@Drewniok Drewniok deleted the round_n_decimal_places branch September 5, 2023 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants