Skip to content

Conversation

@uri-granta
Copy link
Member

@uri-granta uri-granta commented Apr 27, 2023

PR type: bugfix

Related issue(s)/PRs: related to 1985

Summary

Proposed changes

The wrapper for config constants is implemented as an Enum, even though it's not really being used as an enumeration. More problematically, Enums don't work correctly when two members have the same value and result in an alias for the first entry. The PR 1985 has this issue since both LIKELIHOODS_POSITIVE_MINIMUM and JITTER have the value 1e-6.

As proposed by this PR, we simply stop making the wrapper an enum. This forces us to explicitly state the environment variable names alongside the default values, but this duplication is not necessarily a bad thing.

What alternatives have you considered?

We could use an external enum package such as aenum that does support duplicate entries, but this introduces an unnecessary package dependency to GPflow.

Minimal working example

# Buggy behaviour
class _Values(enum.Enum):
     POSITIVE_MINIMUM = 0.0
     LIKELIHOODS_POSITIVE_MINIMUM = 1e-6
     JITTER = 1e-6

print(_Values.JITTER)
<_Values.LIKELIHOODS_POSITIVE_MINIMUM: 1e-06>

Release notes

Fully backwards compatible: yes

PR checklist

  • New features: code is well-documented
    • detailed docstrings (API documentation)
    • notebook examples (usage demonstration)
  • The bug case / new feature is covered by unit tests
  • Code has type annotations
  • Build checks
    • I ran the black+isort formatter (make format)
    • I locally tested that the tests pass (make check-all)
  • Release management
    • RELEASE.md updated with entry for this change
    • New contributors: I've added myself to CONTRIBUTORS.md

@uri-granta uri-granta marked this pull request as ready for review April 27, 2023 09:44
Copy link
Collaborator

@khurram-ghani khurram-ghani left a comment

Choose a reason for hiding this comment

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

Looks good!

@codecov
Copy link

codecov bot commented Apr 27, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (cb88277) 98.06% compared to head (14c1d88) 98.06%.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2066   +/-   ##
========================================
  Coverage    98.06%   98.06%           
========================================
  Files           97       97           
  Lines         5436     5437    +1     
========================================
+ Hits          5331     5332    +1     
  Misses         105      105           
Impacted Files Coverage Δ
gpflow/config/__config__.py 96.45% <100.00%> (+0.02%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@khurram-ghani khurram-ghani merged commit f4904ec into develop Apr 27, 2023
@khurram-ghani khurram-ghani mentioned this pull request May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants