-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fixes to support 0TP27 #13351
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
Fixes to support 0TP27 #13351
Conversation
| iex> Enum.unzip(%{a: 1, b: 2}) | ||
| {[:a, :b], [1, 2]} |
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.
I didn't see a relevant test to be added, a one-size map would hide the fact that the keys are misordered, we already have a keyword above...
| assert Float.ceil(7.5e-3) === 1.0 | ||
| assert Float.ceil(-12.32453e4) === -123_245.0 | ||
| assert Float.ceil(-12.32453e-10) === 0.0 | ||
| assert Float.ceil(-12.32453e-10) === -0.0 |
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.
Was already the case on OTP26, the test was misleading precisely because 0.0 === -0.0 was true
| case rounding do | ||
| :ceil when sign === 0 -> 1 / power_of_10(precision) | ||
| :floor when sign === 1 -> -1 / power_of_10(precision) | ||
| :ceil when sign === 1 -> -0.0 |
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.
Fixing Float.ceil/2 to match Float.ceil/1 and :math.ceil/1
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.
Actually I'm not sure, we might want to rethink this whole rounding spec.
Here is the current behavior:
Erlang/OTP 26 [erts-14.2.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]
Interactive Elixir (1.16.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> for fun <- [:round, :ceil], num <- [-0.0, -0.01], prec <- 0..1, do: IO.puts "#{fun}(#{num}), #{prec}) = #{apply(Float, fun, [num, prec])}"
round(-0.0), 0) = 0.0
round(-0.0), 1) = -0.0
round(-0.01), 0) = 0.0
round(-0.01), 1) = 0.0
ceil(-0.0), 0) = -0.0
ceil(-0.0), 1) = -0.0
ceil(-0.01), 0) = -0.0
ceil(-0.01), 1) = 0.0It feels like we'd want to have to following invariants:
ceil(x) >= round(x)fun(-0.01) <= fun(-0.0)fun(-0.01, 0) === fun(-0.01, 1)
but none of these are currently respected.
How about the following?
round(-0.0), 0) = -0.0
round(-0.0), 1) = -0.0
round(-0.01), 0) = -0.0
round(-0.01), 1) = -0.0
ceil(-0.0), 0) = -0.0
ceil(-0.0), 1) = -0.0
ceil(-0.01), 0) = -0.0
ceil(-0.01), 1) = -0.0Seems consistent with what Javascript and Python are doing:
> Math.round(-0.0, 0)
-0
> Math.round(-0.0, 1)
-0
> Math.ceil(-0.0, 1)
-0
> Math.ceil(-0.01, 1)
-0>>> round(-0.0, 0)
-0.0
>>> round(-0.0, 1)
-0.0
>>> round(-0.01, 1)
-0.0
>>> round(-0.01, 0)
-0.0There 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.
Looks excellent to me, awesome summary and proposal.
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.
OK should be good! 5edfdd6
11e03cd to
5edfdd6
Compare
| iex> {:ok, _} = Registry.register(Registry.SelectAllTest, "world", :value) | ||
| iex> Registry.select(Registry.SelectAllTest, [{{:"$1", :"$2", :"$3"}, [], [{{:"$1", :"$2", :"$3"}}]}]) | ||
| [{"world", self(), :value}, {"hello", self(), :value}] | ||
| iex> Registry.select(Registry.SelectAllTest, [{{:"$1", :"$2", :"$3"}, [], [{{:"$1", :"$2", :"$3"}}]}]) |> Enum.sort() |
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.
* Fix non-deterministic key-value tests * Fix non-deterministic Enum tests * Fix :only option when deriving Inspect * Float.ceil and Float.floor return -0.0 for negative numbers * Fix non-deterministic Registry doctest * Simplify check
This PR fixes most of the small breakage in the CI due to the
-0.0change and non-deterministic order of keys.There is still a breaking test for
Registry, and I haven't looked intoIEx/mixetc yet, will look into it later.