python-sortedcontainers icon indicating copy to clipboard operation
python-sortedcontainers copied to clipboard

irange() when used with neg

Open oedokumaci opened this issue 1 year ago • 0 comments
trafficstars

I am using SortedDict with neg from operators (so that index 0 is lowest key, value pair). The thing is that when I use irange, I need to swap minimum and maximum values to get what I would normally expect. Is this intended?

MWE below:

bid_prices_and_quantities = SortedDict(neg)
bid_prices_and_quantities[1.5] = 5
bid_prices_and_quantities[2.5] = 4
bid_prices_and_quantities[3] = 3
bid_prices_and_quantities[4] = 2
for price in bid_prices_and_quantities.irange(minimum=2, maximum=3):
    print(price)

this does not print anything.

for price in bid_prices_and_quantities.irange(maximum=2, minimum=3):
    print(price)

this prints as expected: 3 2.5

oedokumaci avatar Apr 02 '24 09:04 oedokumaci