Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

feat: add support for Decimal and Decimal score types #110

Merged

Conversation

Christopher-Chianelli
Copy link
Collaborator

  • Decimal maps mostly to BigDecimal, although its floating point concepts are ignored (Python does not have an infinite precision MathContext, so it acts more like a dynamic range floating point with an adjustable precision. The precision used is shared in a thread local object that can be changed using decimal.setcontext.

  • Added str constructors to float and int

  • Added sanity tests for all variants of penalize/reward/impact and score types

- Decimal maps mostly to BigDecimal, although its floating
  point concepts are ignored (Python does not have an infinite
  precision MathContext, so it acts more like a dynamic range
  floating point with an adjustable precision.
  The precision used is shared in
  a thread local object that can be changed using
  decimal.setcontext.

- Added `str` constructors to `float` and `int`

- Added sanity tests for all variants of penalize/reward/impact
  and score types
Copy link
Contributor

@triceo triceo left a comment

Choose a reason for hiding this comment

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

Leaving some comments.

A question regarding LoadBalance - the class has a BigDecimal-returning method. I don't see any code handling that here. So the conversion to Python Decimal happens automatically?

@triceo triceo linked an issue Jul 12, 2024 that may be closed by this pull request
@Christopher-Chianelli
Copy link
Collaborator Author

All Java methods that return BigDecimal are automatically translated to PythonDecimal instances.

Copy link
Contributor

@triceo triceo left a comment

Choose a reason for hiding this comment

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

LGTM after we're back to at least B in Sonar.

(We may have to disable the ThreadLocal rule there, even though it's entirely correct and points out the main reason why ThreadLocal should be avoided.)

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@Christopher-Chianelli Christopher-Chianelli merged commit 1c7d902 into TimefoldAI:main Jul 12, 2024
7 of 8 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat: DecimalScore in Python
2 participants