Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Creating anIntEnum programmatically#1577

Answeredbywhitequark
goekce asked this question inQ&A
Discussion options

I have an integer range that I want to encode so that the encoding begins at zero. I used anIntEnum which should act as an encoder and decoder. Because the range is large, I want to create it programmatically. PythonIntEnum supports the following, but AmaranthIntEnum with ashape does not:

fromenumimportIntEnumaspyIntEnumsum_range=range(4,21+1)SumEnum=pyIntEnum('SumEnum', {f'SUM_{x}':x-4forxinsum_range})display(type(SumEnum))# enum.EnumTypefromamaranth.lib.enumimportIntEnumasamaranthIntEnumSumEnum=amaranthIntEnum('SumEnum',names={f'SUM_{x}':x-4forxinsum_range},shape=unsigned(5))# TypeError: EnumType.__call__() got an unexpected keyword argument 'shape'

What would be the right way to create an Enum programmatically? I am new to Amaranth, so an alternative Amarantish approach is also welcome.

You must be logged in to vote

This is a known bug:#1535

I think if you ask in the IRC/Matrix channel, someone might help you out with it.

Replies: 1 comment

Comment options

This is a known bug:#1535

I think if you ask in the IRC/Matrix channel, someone might help you out with it.

You must be logged in to vote
0 replies
Answer selected bygoekce
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@goekce@whitequark

[8]ページ先頭

©2009-2025 Movatter.jp