question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Summarize integer type promotion rules with a lattice?

See original GitHub issue

@jakevdp suggested that a nice way to summarize the signed/unsigned integer type promotion rules would be with a lattice, e.g., image

i* denotes a Python int (with unspecified precision).

This is a subset of the full type promotion lattice from the JAX docs: https://jax.readthedocs.io/en/latest/type_promotion.html

The lattice for floats would just be f* -> f4 -> f8.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:32 (23 by maintainers)

github_iconTop GitHub Comments

2reactions
jakevdpcommented, Dec 17, 2020

Fair enough.

My first time through the doc, it took me five minutes to peruse the several tables and get a big picture view of what they were saying, and even then I didn’t understand how Python scalars play into things until my next read-through when I noticed the “Notes” section below them. I would have grokked all of that in under 15 seconds had there been a lattice displaying the same information.

1reaction
jakevdpcommented, Dec 17, 2020

The styling looks really nice!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Implicit type promotion rules - Stack Overflow
Whenever a small integer type is used in an expression, it is implicitly converted to int which is always signed. This is known...
Read more >
INT02-C. Understand integer conversion rules
Integer promotions require the promotion of each variable ( c1 and c2 ) to int size. The two int values are added, and...
Read more >
Type Promotion Rules — Python array API standard 2021.12 ...
Type promotion rules must apply when determining the common result type for two array operands during an arithmetic operation, regardless of array dimension....
Read more >
NOTE 223 – Lattice Expression Language - Casacore
An expression can be seen as a lattice (or image) in itself. ... Mixed data type arithmetic and automatic data type promotion. Support...
Read more >
Type promotion semantics - JAX documentation
This document describes JAX's type promotion rules–i.e., the result of ... type promotion behavior is determined via the following type promotion lattice:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found