-
Notifications
You must be signed in to change notification settings - Fork 284
fix math of calculating scaled price for marketplace #3976
Conversation
5e16c39
to
6e66144
Compare
golem/marketplace/offerpool.py
Outdated
@@ -9,6 +10,12 @@ | |||
logger = logging.getLogger(__name__) | |||
|
|||
|
|||
def scale_price(task_price: float, offered_price: float) -> float: | |||
if offered_price == 0: | |||
return sys.float_info.max # using float('inf') complicates calculations in rust part |
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.
What kind of complications are we talking about? It fails with an error? There's test_rust.py
which is supposed to test proper integration with Rust and I'd expect a test there that guarantees no "complications in rust part".
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.
The complication was not because of python-rust communication of float('inf')
value, but because of calculations done in order_providers_impl
(for which I expanded tests in marketplace.py
file).
The problem is when alpha = 0
, because inf * 0 = nan
. And using inf
would totally break cases when 0 < alpha < 1
, because the score would be always inf
.
By using float max it's at least giving a good impression of behaving correctly. I tried to talk with @mbenke about it, but he's not responding right now.
68a6206
to
ed2fea7
Compare
ed2fea7
to
fe62254
Compare
fe62254
to
bb471cc
Compare
Codecov Report
@@ Coverage Diff @@
## b0.19 #3976 +/- ##
==========================================
+ Coverage 89.18% 89.19% +<.01%
==========================================
Files 205 205
Lines 18315 18320 +5
==========================================
+ Hits 16335 16341 +6
+ Misses 1980 1979 -1 |
bb471cc
to
2c32d56
Compare
msg.price / task.header.max_price
back totask.header.max_price / msg.price
Related issues: #3453, #3479, #3964