Repository navigation
Reject an explicit zero float width instead of the IEEE default #6515
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -126,8 +126,16 @@ def __init__( | |||||||||
| self.type_id = type_id | ||||||||||
|
|
||||||||||
| if kind == DType.Kind.float: | ||||||||||
| self.exponent_bits = exponent_bits or DType._default_exponent_bits(bits, True) | ||||||||||
| self.significand_bits = significand_bits or DType._default_significand_bits(bits, True) | ||||||||||
| if exponent_bits is None: | ||||||||||
| exponent_bits = DType._default_exponent_bits(bits, True) | ||||||||||
| elif exponent_bits < 1: | ||||||||||
| raise ValueError(f"Invalid number of exponent bits: {exponent_bits}") | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Style] The new errors for Use messages such as Rule Used: Error messages must name the affected parameter/operator, show expected vs. actual values, and end as a complete sentence. Not Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||||||||||
| if significand_bits is None: | ||||||||||
| significand_bits = DType._default_significand_bits(bits, True) | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| elif significand_bits < 1: | ||||||||||
| raise ValueError(f"Invalid number of significand bits: {significand_bits}") | ||||||||||
| self.exponent_bits = exponent_bits | ||||||||||
| self.significand_bits = significand_bits | ||||||||||
| else: | ||||||||||
| self.exponent_bits = None | ||||||||||
| self.significand_bits = None | ||||||||||
|
|
@@ -278,7 +286,17 @@ def parse_internal(name: str) -> "DType": | |||||||||
|
|
||||||||||
| t = parse_internal(name) | ||||||||||
| if t.type_id is None: | ||||||||||
| t.type_id = _type2id[t] | ||||||||||
| try: | ||||||||||
| t.type_id = _type2id[t] | ||||||||||
| except KeyError: | ||||||||||
| # __init__ caches the temporary type before this lookup. Drop that | ||||||||||
| # entry so a later parse does not return the rejected type. Leave a | ||||||||||
| # name that already pointed at a different type alone. | ||||||||||
| if _name2type.get(t.name) is t: | ||||||||||
| del _name2type[t.name] | ||||||||||
|
Comment on lines
+295
to
+296
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Bug] A failed Save and restore any prior entry, or avoid caching temporary types until the lookup succeeds. |
||||||||||
| if name != t.name and _name2type.get(name) is t: | ||||||||||
| del _name2type[name] | ||||||||||
| raise ValueError(f"{name} is not a registered type.") from None | ||||||||||
| if t.type_id is not None: | ||||||||||
| t = _id2type[t.type_id] # use the same DType instance as the one registered with the id | ||||||||||
| _name2type[name] = t | ||||||||||
|
|
||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.