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

Signal: allow to use integral Enum for reset value. #296

Merged
merged 1 commit into from Jan 11, 2020
Merged

Signal: allow to use integral Enum for reset value. #296

merged 1 commit into from Jan 11, 2020

Conversation

Fatsie
Copy link
Contributor

@Fatsie Fatsie commented Jan 6, 2020

Follow-up to #294.

@@ -834,6 +834,11 @@ def __init__(self, shape=None, *, name=None, reset=0, reset_less=False, min=None
attrs=None, decoder=None, src_loc_at=0):
super().__init__(src_loc_at=src_loc_at)

if isinstance(reset, Enum):
reset = reset.value
if not type(reset) == int:
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be an isinstance(reset, int), or reset=True will fail. (bool is derived from int in Python.)

@codecov
Copy link

codecov bot commented Jan 6, 2020

Codecov Report

Merging #296 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #296      +/-   ##
==========================================
- Coverage   82.13%   82.13%   -0.01%     
==========================================
  Files          34       34              
  Lines        5647     5652       +5     
  Branches     1160     1162       +2     
==========================================
+ Hits         4638     4642       +4     
- Misses        864      865       +1     
  Partials      145      145
Impacted Files Coverage Δ
nmigen/hdl/ast.py 87.15% <100%> (-0.05%) ⬇️

Continue to review full report at Codecov.

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

nmigen/hdl/ast.py Outdated Show resolved Hide resolved
@whitequark
Copy link
Contributor

Thanks. Could you add a test as well?

@Fatsie
Copy link
Contributor Author

Fatsie commented Jan 9, 2020

Pushed a test.

@Fatsie
Copy link
Contributor Author

Fatsie commented Jan 9, 2020

Pushed change that removes reference to bool in docstring and extended test to check for non-integral Enum type.

nmigen/hdl/ast.py Outdated Show resolved Hide resolved
@Fatsie
Copy link
Contributor Author

Fatsie commented Jan 10, 2020

ValueError -> TypeError

@whitequark whitequark merged commit e4e2671 into m-labs:master Jan 11, 2020
@whitequark
Copy link
Contributor

Thanks for the PR!

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.

None yet

2 participants