« first day (3190 days earlier)      last day (1981 days later) » 

user10984358
15:01
x.name instead of x
user10984358
works peachy !
user10984358
the docs has some example with startswith
user10984358
yup
user10984358
before the docs I was trying indexing it, terrible idea from the start, idk why I thought it would work
15:03
disclaimer: all errors in code snippets are purely for educational purposes... ;)
user10984358
can't deny, I learnt how to use something new
@TheNamesAlc that's actually a good sign. You should experiment in the REPL rather than defaulting to asking questions
Lesson: snippets you receive from experts in here should receive the same level of scrutiny as code you wrote yourself
user10984358
yeah I was just carried away given the fact I came in here asking for something else related to this, but yeah your point stands
And even a properly setup REPL (and especially REPLs on steroids such as ipython) will give you hints of attributes with tab completion of methods. And you can look at help(obj) too. All this without having to google the docs.
15:05
If you are using endswith to detect file endings, and you may match on multiple endings, don't forget that endswith will accept a tuple of all interesting string endings
@TheNamesAlc we've been having a spike of people who do more asking than thinking these past week or two, which is why I'm giving you a harder time
list(filter(lambda s: s.endswith(('.jpg', '.png', '.gif')), "xyz.gif xyz2.png blah.py xyz3.jpg".split()))
user10984358
thanks for the tip
Based on chat.stackoverflow.com/transcript/message/46739054#46739054 The initial number must be chosen from a linearly weighted distribution of integers. Namely, a uniform choice of np.arange(1, 99).repeat(np.arange(98, 0, -1)). The second number can be chosen uniformly from set(np.arange(1, 99)) - {what_ever_was_chosen_prior}. The last is 100 - first - second
@PaulMcG tuple, but not list :|
@piRSquared including repetitions with order?
I guess you can test hypotheses like that empirically, comparing with the full permutation approach
user10984358
15:07
@AndrasDeak its not bad, I saw you referring someone to not be a help vampire like two days back, some dude about pandas and google map url
yes, I think so. function incoming
@TheNamesAlc indeed
user10984358
@PaulMcG I was expecting something like this with glob when I came in here but guess I will default to scandir or multiple globs for readability
@AndrasDeak I've yet to generalize to more numbers (higher dimensions)
3 is enough as it is
15:11
there is no 3, just n
I thought you were a physicist :P
check 3 and 4, then extrapolate to n ;D
I tend to dabble :P
import pandas as pd
from itertools import product

n = 10
i, j, *k = zip(*filter(lambda t: sum(t) == n, product(*[range(1, n)] * 4)))
c = pd.value_counts(j).sort_index()
print(c, c.diff(), sep='\n\n')

# 1    28
# 2    21
# 3    15
# 4    10
# 5     6
# 6     3
# 7     1
# dtype: int64

# 1    NaN
# 2   -7.0
# 3   -6.0
# 4   -5.0
# 5   -4.0
# 6   -3.0
# 7   -2.0
# dtype: float64
^ 4 d
I'm still not convinced your generation method is sound but I don't have the bandwidth to seriously think about the problem
I'm still thinking about how to generate random points lying inside an equilateral triangle.
15:14
Cartesian product of range(1, 10) filtered by those tuples whose sum is 10
I am decently sure you can just throw combinatorics at that and be done with it
Step 1. Inscribe an equilateral triangle inside the unit square. Step 2. Generate two reals in [0,1). Step 3: ???
@Kevin Did you get your namespace sorted the other day?
Well yam! My bandwidth is now depleted... thanks for playing.
@Kevin well rejection sampling always works...
15:17
@holdenweb I ended up just using a dict.
you can easily take a convex combination of the vectors pointing from the center to corner of the triangle, but that won't be uniform at all
@AndrasDeak As in, generate random points and discard the ones lying outside the triangle? Yes, but I think you can do better.
yup
You can do rejection sampling with two reals generated in the unit circle into which the triangle is inscribed... ;)
less cookie dough to be cut away
An equilateral triangle's area is exactly half the area of the rectangle that circumscribes it. So you only need a function that maps "points lying in the rectangle" to "points lying in the triangle", and you can generate points in constant time.
15:22
but that's not a linear map...
Or is it?
I think it is
no, it's not
oh, rectangle, not square, hold on
Yeah, you can cut it up and reorder.
not strictly speaking linear because you have to treat the two halves separately, but definitely doable analytically
For every point in the triangle there are two points in its "circumscribed" rectangle
Perhaps there's a good modulo which you can use to handle it in one step?
you can definitely (maybe) use a single expression involving an absolute value
@piRSquared Or the converse, for every point in the rectangle, it will map to itself or its twin inside the triangle.
15:25
zactly
Bonus: it works for isosceles triangles.
Rotate 180 instead and I think you got all triangles... maybe... at least more than just isosceles
I suspect there's a single expression that can do this. Because something something triangles tessellate the plane something something.
All acute ones
15:29
odd distinction, are you sure?
I guess any triangle can be flipped over to create a parallelogram which can then be used to tessellate
Always start with largest side as the base, then apply 180 rotation then it should be good for all triangles
Sounds good to me.
but if it's an isosceles triangle it might not have a largest side D':
15:31
I'm 65% sure you can pick whichever side you want, largest or no
yup
I dare give it 95%
That depends if you believe in the axiom of choice.... (runs away)
I just need a function that "folds" the unit square so that any point to the right of the line y = 1-x gets reflected over that line, and any point to the left stays where it is.
I bet I need to use abs()... As usual Andras is thirty minutes ahead of me
there's still chance we're both wrong
There aren't that many idempotent functions we can choose from
It's this or sqrt(x**2) :-P
15:46
A silly test if I may: this site is something that I want to link but it is annoying enough for me and I don't have complex adblockers. There's nothing malicious (that I'm aware of, it's "wired.com") but I'm curious whether your adblockers make it crap out or actually help to make it sufferable. The article's numbers are handy for me, but I fear I need another source.
Maybe the problem is easier with polar coords...
@roganjosh there's text that ends with "200—The number of data points [...]"
if that's all then yeah, it works fine without JS
I have an adblocker and I can read that page. After I dismiss two separate pseudo-popups asking me to subscribe.
@Kevin probably not, because metric is more difficult in curved coordinate systems
It says "three free articles left this month". I suspect that I wouldn't be able to the read the page if I had zero free articles left.
15:49
Ok, thanks guys. I also get that ridiculous banner saying I've used 50% of my free entitlement multiple times
you're not entitled enough
It seems not :'( I don't know why sites insist on blowing themselves to pieces with this crap. I've actually had that link a long time and I wanted to reference the financial implications of vehicle routing, but checking back on it before using it shows some serious deterioration with the site
I'll have a look for some other sources anyway. It's not easy to find articles that are accessible to people outside of the technical side that summarise the problem and the financial impact
16:44
is there an idiomatic way to evaluate a def or class immediately? I've seen @object.__new__ used for classes to create singletons, but it seems awfully obscure
What do you mean by evaluate a def or class?
In python evaluating a def means that a name is entered in the symbol table and its body is stored for execution when you call the function.
But I think you are asking about calling the function or creating an instance of the class. so if you have def foo(): pass you can do foo() to call it.
So, something like this?
def called_immediately(func):
    result = func()
    return lambda: result

@called_immediately
def meaning_of_life():
    print("Hmm, let me think about that.")
    return 42

print("About to call meaning_of_life().")
print(meaning_of_life())
print(meaning_of_life())

#result:
#Hmm, let me think about that.
#About to call meaning_of_life().
#42
#42
@Kevin imagine the vector from the first point on the triangle to the second (Cyan on my chart). Name it tri_1. Then the vector representing a point chosen outside of the triangle (Black on my chart). Name it x. The New vector that will be inside the triangle (red in my chart) is the difference between the two. tri_1 - x
@Kevin basically without repeating the () on meaning_of_life
I don't see the use case for it, but decorators can return noncallables if you really want:
def called_immediately(func):
    result = func()
    return result

@called_immediately
def meaning_of_life():
    print("Hmm, let me think about that.")
    return 42

print("About to call meaning_of_life().")
print(meaning_of_life)
print(meaning_of_life)

#result:
#Hmm, let me think about that.
#About to call meaning_of_life().
#42
#42
16:49
Hello I am barred from asking any more questions. What shall I do to get it lifted?
it is mostly for cleaning up/hiding temporary data/functions/classes
I guess print("About to call meaning_of_life().") is not actually representative of what's happening since you aren't calling it anymore
@Man_From_India see this
The outlook is not good, btw
Ah I see. Yes I had to ask questions, agreed that they are unclear. But I do get very little time, so most of the time when I talk I talk on phone and during my travel from and to office. I'm not a software professional by the way. I asked questions on desktop but I really got very little time to ask. Now finding ways to improve my old questions.
I have a vague longing for improved namespace support in Python, but I don't actually know what that would look like. A namespace <identifier>: block that does nothing but create a scope local to itself would be a start.
17:02
@Kevin actual example:
@object.__new__
class NiceSlice:
    """Slice that can be created using slice notation"""
    def __getitem__(self, item: slice) -> slice:
        assert isinstance(item, slice)
        return item

    def __call__(self, start_stop, stop=None, step=None) -> slice:
        if stop is None:
            return slice(start_stop)
        return slice(start_stop, stop, step)
@Man_From_India I can sympathise to a point but it's not helpful to post half-baked questions in a hurry and not be in a position to test the results. It drives me slightly nuts when I give suggestions to a question and end up waiting days to get feedback. You can edit your questions in accordance to the link I gave, but question bans seem to be a bit of a black hole, and I know you got the warnings because I did too when I started out, you just didn't take them on board.
I was not sure when did I get :( because as I said I hardly get any time. Well this site is too strict to new users than other Stackexchange sites.
I have only one question to edit. I will do it from computer, now I am already on bed.
Will it be lifted at all? I mean the ban.
I think it is unlikely (to manage your expectations) but perhaps. The site is not necessarily too strict, we're faced with a deluge of bad questions (especially the Python tag) and you may well just get caught up in it if the question isn't clear.
:'(
I started learning it, but this ban! A huge loss :'( don't know without your help how will I learn.
Hmmm I will try editing my questions :'( let's see if it is lifted.
17:17
I don't actually follow why you should be banned here. Your questions are net-positive by 2 votes
Have you deleted posts?
@roganjosh it's not just net score that counts
few downvoted, few lukewarm upvoted can still be banned
at worst you can ask questions to improve your stats every 6 months
Seems a bit overbearing in this case but it's not worth me arguing against that system
@Man_From_India you do have two heavily downvoted posts from 2014 that were deleted but not by you...
^ that explains it
17:22
I want to join all the parameters that are passed in a function into a string, I came up with this
def findIDFromText(name, address=None, cp=None, city=None):
    lista = [name, address, cp, city]
    text = ''
    for elem in lista:
        if elem is not None:
            elem = str(elem)
            text = text + ' ' + elem
            print(text)
    return text
Oh :'( so it must be the reason. If it is deleted, I can't remember what I asked that time :'( if only I got a chance to improve them :(
@JonClements now what should I do in this situation?
findIDFromText('burger king', 'malasaña 23 barcelona', 28046, 'Barcelona') is working but kind of slow
@reydonsancho ' '.join([str(item) for item in lista if item])?
@Man_From_India don't worry about those ones... looking at 'em I don't think you'd be able to do anything with 'em anyway... worry about the most recent ones... see meta.stackexchange.com/questions/86997/…
@roganjosh Thks!
17:25
Hmmm I only edited one question but not getting any votes or feedback. If this is the case what else will I do?
@reydonsancho You're welcome. Do you understand how it works?
be patient...
-1
Q: PyQt5 know default values of objects

Man_From_IndiaWhen we create any object (in my case widget, of course an object) it has got some default values. For example when we write a code like this: button = QPushbutton() On screen we see a graphical representation of a button. It has some default values that is taken care of automatically by defa...

I endorse the str.join solution, since it is more efficient than concatenating to a string in a loop. But even so, concatenating just four values shouldn't be slow enough to notice a difference. I suspect something else is going on.
@JonClements ok :'(
17:26
We're talking a gain of milliseconds here
@roganjosh Not so well, the tricky part for me is why if item is None why it is not appended?
Well, none of the function params are used, so I assume the issue involves them
but when I instantiate the list I call the params
@reydonsancho None is falsey so if item will reject those values because it only accepts truthy values in the final list
mmm I see
makes sense, thks!
17:31
I should stop being blind, of course you use the params, you just put them into a list. Apologies. Long day :/
@reydonsancho do you even really need a function for that - the only point I can see of doing so is to make sure that at least name is present...
I see new user posting the same question: 1. question stackoverflow.com/questions/56991445/… today, 2. question now stackoverflow.com/questions/56994504/…. What to do in this case?
They're not dupes IMO. The OP has decided that they can just keep SO-ing the way through their issue, which is not uncommon
@reydonsancho is the code as shown slow? note that printing takes considerable time
17:58
@MisterMiyagi well, it's not the same "slow" between computing and printing (like: n = 2 ** 1_000_000; print(n) is), but it's just not a great way of concat'ing strings...
Hi guys can someone tell me what am I doing wrong for this problem? codechef.com/problems/PERMUT2
Here is the MCVE link:
It works perfectly fine in my IDE
a = list(map(int, input().split())) shouldn't that be a = list(map(int, n.split()))?
Why n.split()? @roganjosh
n is just a number, a is the actual string input that I am taking
Because you already solicited input with n = int(input())
Yeah but I am taking the number of values with that
18:06
n.split() won't work because n is an integer and not a string
Yeah, I'm backing out of answering tonight. It doesn't make sense to split an int input, but then this question entirely lacks context so I've just fallen into a hole
Your code always calls input() an even number of times, but the sample input has an odd number of lines. This is a problem.
Remember that a while loop will not terminate halfway through if its condition suddenly changes. while n != 0: will not notice that n has become zero until the very end of the block.
You need the block to terminate after you call n = int(input()) but before you call a = list(map(int, input().split())). One way to do this is to change the loop to while True: and put if n == 0: break in between the lines that assign n and a
Another way to do it is to keep it as while n != 0:, but move the n = int(input()) line to the very end of the loop. But then you would have to also put a second n = int(input()) right before the while loop starts, which violates DRY principles
Like this? @Kevin
n = 1
while True:
    n = int(input())
    if n == 0:
        break
    a = list(map(int, input().split()))
    flag = 0
    for i in range(len(a)):
        if a[i] != a.index(i + 1) + 1:
            flag = 0
        else:
            flag = 1
            break
    if flag == 0:
        print('not ambiguous')
    else:
        print('ambiguous')
That should do. Btw, your solution looks like O(n**2) and is likely break time limit
What would be a better approach? @QuangHoang
18:18
@RaphX That's what I had in mind, yes. You can also delete that n = 1.
You can create loop the array once to create an array of indexes, something like:
indexes = {v:i for i, v in enumerat(a)}
and use indexes[i] instead of a.index(i+1)
That's make your solution O(n)
One lazy O(n log(n)) solution is to check if a == sorted(a, key=lambda x: a[x-1]) at all values.
I think storing indexes is a good idea, but it might need a little tweaking to work with the starting-from-one-indexing the problem uses.
@Kevin totally, i always hate them problems with 1-index
Fencepost errors are one of the three Top Two Most Difficult Problems In Programming after all
Thanks for the help!@QuangHoang@Kevin
18:26
@Kevin might be able to just use enumerate(whatever, start=1) blah blah blah
@JonClements Now this is something I didn't know. Cool.
I agree that two-argument enumerate will be useful here. I just don't know if it's all that is needed. Do not ask me to add small numbers around 2:30 PM, it won't go well.
@QuangHoang if your arrays also index from 1 it's perfectly fine
@Kevin is one in a One, Two, Three, Many, Many-One, Many-Two, Many-Three, Many-Many, Many-Many-One moment then? :p
I can only count to Lots unless I'm wearing my special helmet with the ice pack inserts
18:31
ahh... this'd explain the lack of delivery of the LOTC I guess...
The accumulated heat from the dozens of tea kettles interferes very badly with the helmet.
18:50
so... are you suggesting that one needs to stop drinking tea to get a better tea delivery system implemented?
19:05
Umm, wut?
I've never seen that before, and I could already do all of those things
fortunately the new mobile version is still crippled
I like consistency. Hurrah for that, at least.
19:22
It's a bit sad that I started this morning faffing from scratch with responsive designs and now have to site that works on mobile and desktop on the front-end but they're still unable to work with chat properly. The back end is a pain to sort, but it boggles my mind that we still have this after years
19:35
well chat works, it just lacks features...
It's pretty awful as an interface but I also kinda get the feeling this room is one of the last bastions of actual discussion
no, JS and java and PHP are definitely all active I think
c# and rust too, probably
Checked them and fair, they're not just bot rooms
I don't think I had a bigger point to make beyond "I'm pretty poop at front-end and did more in a day than the site bothers to do" :)
"I wish chat got more attention from the devs", I say, and the monkey's paw curls one finger inwards. Meanwhile, at SO HQ, management tells the devs "we can only afford to work on features that draw revenue". "I have an idea," says the dev, "let's cram chat full of ads"
does anyone know some equivalent to the builtin hash that does not use salting?
we need to calculate siphash-like hashes for nested Python objects, but they must be stable across invocations
19:50
Maybe hashlib has something.
I've only found libraries that replicate the hashlib interface, which works on bytes :/
repr().encode() :>
Ugh, got Kevin'd on that one - thanks @Andras... sitting thinking though why that'd ever be a requirement
(well, anything practical you'd ever want to do so even if you can)
@MisterMiyagi can you set salt to b''?
afternoon all
19:57
cbg
hoping someone much smarter than myself can help me out here, been beating my head against a wall all day
I have this set of data: pastebin.com/MX40EHK2 trying to break it into a dictionary. the data is (x,y), (x1,y1), etc. i really can't seem to figure out how to break it down. I'm also trying to round it to a single value (119.25 and 119.53 would both round down to 119 and it would keep the last value on that int)
is it really a text file or a string, or rather a list of tuples?
And break it into a dictionary how? If it's a list of tuples then dict(your_list_of_tuples) should readily give you a dict
119.53 would round down? What about 119.99?
119.99 would round down too
you can implement the truncation with something like {k:int(v) for k,v in your_list_of_tuples}
20:02
@AndrasDeak right now it's a string that's purely what is in the pastebin
right now it's set as a string
lemme make a gist real quick
btw: this is on that silly lidar again
ast.literal_eval will turn your string into the corresponding list of tuples
a = {item[0]: item[1] // 1 for item in a} where a is that list of tuples
I'm totally open to redoing this...my brain hurts and I just want to get back to embedded haha
OK. So go back to square one. Explain your problem in light of your python code, in clear and unambiguous terms.
take your time
20:11
So let's just hang-fire for a bit until you get an MCVE in place that illustrates the problem :)
So I'm sending a start command (the xA5x60 in G4_API.py) and letting the scanner start then reading in chunks (the read(1024) and splitting it by the delimiter they gave (xaax55) then returning that to a variable in my main python file
Good so far?
you will have to explain 1. what your code is supposed to do, 2. what it does instead, 3. what the yam data.txt is, 4. whatever else might arise
I'd still say stop tbh
I wish you all had one of these to see what's going on so you could fire it up haha
20:13
you started with "how do I convert this string to a dict" and now we're reading chunks from a lidar
It's not a bad problem, but make sure you have the whole package to go at once
I have the chunks, now I'm trying to mess with the chunks
then abstract away the lidar
I don't have to know where your data is coming from as long as you define in clear terms what your data really is
so i'm getting the data in data.txt It's in (distance,agnle) form. I want to floor the angle (so all 199.xxx go to 199) and store the last distance of the 199 angle into a list so I can access it later
20:15
I'm really trying here
> so i'm getting the data in data.txt It's in (angle,distance) form.
Is that done by the code fragment you showed? Or the output of unrelated code?
I'm still trying to figure out what data.txt really is since that's what you asked about first
That is in the code fragments.
data.txt is the return d in G4_API.py
i just copied it to a text file to show here
right now its in my terminal
Copied what exactly to a text file?
print(data)?
yes
OK
print(type(data)) too, please, and see what it says
20:18
Ok so that's where I was getting confused. If the scanner gets bad data, it returns False, so data is a bool. However, if it's good data it's a list.
okay, that makes sense in a horrible API kind of way
I agree haha
I'm working with somethign that the manufacturer can't even help with....so I'm all on my own on this
so...what you have is a list of tuples when it's OK, or False when it's not OK, and you want a dict when it's OK
That is correct
20:19
That aside. What do you mean by scanner? It's something like a barcode scanner writing to a file?
So we can get back to your question now.
@roganjosh it's a 360 lidar
@roganjosh LiDAR
(a radar that works with visible light, for those unfamiliar with the term)
measures distance, maybe even speed if it's extra fancy, I'm not sure if they do that
I know the term, I forgot what got thrown to the rotating knives :)
mine does speed if i want it to
20:21
biggi's been struggling for a longer while with that thing
kind of, i had it working
2 mins ago, by Andras Deak
So we can get back to your question now.
@biggi_ so what, specifically, did you change?
see our early messages for how to convert the list of tuples into a dict with or without truncating the values
i had it working for a while then hit a snag in our application so I'm bypassing their API now that was bad making my own
20:24
This is fluff. I'm not honestly bothered about your struggle in relation to going alone, I only want to try fix the issue it presents
What do you plan to do with the time:coordinate pairs? Because pandas might benefit you down the line.
I'm only using the distance:angle (I had it backwards earlier) and then off that I'm calculating a best fit line (already have that done)
nevermind, I just meant x:y
for any kind of numerical thing you should consider using numpy, at which point np.array(list_of_tuples) would give you a 2d array
i'll be sure to look into that one
i think my main hangup at this point is flooring the y portion of (x,y) and only storing one x value into it
> and only storing one x value into it
that's new
20:27
Ok so:
and there won't be any automatic solutions if you have overlapping x or y coordinates; you have to make a conscious decision on what to do with redundant data
If I have (120, 199.1), (132, 199.3), (143, 199.7) I want to just store it as (x:199)
So that way I can just pull the 199 value out of the dict/array
Are you done? Because I don't get it at all.
20:30
I'm thinking of how else to explain.
I should probably just be done
Move back to my embedded and tell the project lead to get the manufacturer to fix their own stuff before trying to do it myself ;)
I mean you can do that, but I don't think the current situation is that dire :P
I'll make it easy for you: add 2 more example tuples with the same rounded y value that is not 199, and tell me what dict you'd like for that
So my data variable looks like this (37200, 119.25053192557316), (36740, 119.53004632265232), (36652, 119.8095607197315).......
There's multiple values for 119, right?
that's topologically the same as your previous example
What are your dealing with, btw? You say "manufacturer" so I'm curious
there was nothing wrong with the example, the explanation (and reply to my question) was lacking
20:33
@AndrasDeak so the (x,y) there are multiple 119.xxxx right?
4 mins ago, by biggi_
If I have (120, 199.1), (132, 199.3), (143, 199.7) I want to just store it as (x:199)
1 min ago, by Andras Deak
I'll make it easy for you: add 2 more example tuples with the same rounded y value that is not 199, and tell me what dict you'd like for that
please do that for me ^
@roganjosh I'd like to not interfere with the internal use of hash, there is a reason for salting in the first place after all
otherwise we're talking right past each other, it seems
So if I have: (1, 119.1), (2, 119.3), (3, 119.6), (4, 120.1), (5, 120.6), (6, 121.8) then I want to store is (3, 119), (5, 120), (6, 121)
Does that make sense?
FINALLY!
20:35
woot
Why 3 and 4 in the output? Because they are the last ones?
Yes
Okay. Do you see why I'm a bit annoyed?
I do
And I promise I'm just as frusterated (not at you, but more because of my own ignorance) haha
20:37
you can automatically get rid of the duplicates you want by creating a dict that is keyed to your truncated floats
@biggi_ the annoying part is that you refuse to give the exact information we're asking for, which can't be blamed on your ignorance
To be 100% honest: I thought I was answering what you were asking. I am sorry if I was not, it's been a long day (and that's no excuse)
{int(angle):dist for dist,angle in data} should be {119:3, 120:5, 121:6}
You were originally asking for a dict but now you showed a list of tuples. What is it that you want to end up with?
@AndrasDeak you mean 121:6
You said something about being able to "pick the angle", which suggests that a dict with angle keys is exactly what you need
@PaulMcG indeed, thanks, edited
@AndrasDeak yes, i'd like a dict. I'm going to be pulling say angles 160-190 out and doing some wonky calcs.
20:40
yeah, again not a full answer
dict of angle -> distance or dict of distance -> angle?
Side note, for when we're done with this part: technologically speaking, why do you insist on truncating? I'd think that an angle of 119.999 should belong to 120 degrees.
i believe dict of angle (I want to use my angle as the key)
@biggi_ OK, so I think I've already given you the answer
So I'm truncating because I thought that would be easier to overwrite data later. For instance, if I had (15,181.3) and (16, 181.6) on one scan iteration, then on the next iteration I got (15, 181.4) and (19,181.7) technically the old iteration would be old data. So I'm truncating to overwrite each time I get new data.
@MisterMiyagi isn't that contradictory? The hash algorithms should be the same and you want the hash with salt
@biggi_ I'm not following. What would be different if you were rounding rather than truncating?
to be clear I'm (we all are) only debating truncation vs rounding
20:44
Nothing probably. That's just the way I had it in my head.
OK, then I (and probably roganjosh) strongly suggest rounding instead
That's fine :) I can do that
Just curious, @biggi_ you have your data in txt and you want to convert into a dict?
this would also mean that if you tried to create integer angles, then 120.01 and 119.99 would both round to 120, whereas the latter would truncate to 119
@QuangHoang no, it's a list of tuples in memory
Quang, we're good on that.
That's true.
20:46
@biggi_ oh, and don't forget to check if not data: for the "False (or empty list)" case
yup i already managed that :)
ty for the reminder
OK, just making sure
There should be a quicklink (whatever you call [mcve] etc) for a kitten picture. All is once again in balance. Peace :)
I'm asking since if it is text on disk, we can read the whole thing and do a regex to extract the the pairs and truncating at the same time.
no it's not on disk
20:48
Then nvm :-)
@QuangHoang noooo
that has to be way slower than converting to a list and truncating floats, right?
@AndrasDeak @roganjosh thanks for the help and sorry for ignorance ;)
no worries, just try to be more exact
@biggi_ no need to apologise to me, and I also didn't do the majority of the leg-work. Glad it's solved for you.
@AndrasDeak That's what I was wondering, instead of scanning strings and converting to float and truncate, which might yield some rounding errors if int part are too big, truncating the strings seems to be a better options
But I guess it's not relevant to this case
That is not a kitten. But cute, so I'll let it slide :P
@QuangHoang I don't see how there could be rounding errors when reading from text
You don't have rounding error reading from text. but int(float_var) might
How?
Or perhaps: what do you mean by "rounding error"?
after all float64 have to reserve some bits for floating.
and can't match integer resolution of int64 is it not?
20:54
OK, I see what you mean, yeah
even if int64 is not big enough, python ints are arbitrary-precision
But then again, it's no issue for this data.
so you're right, thanks
I missed the last step where the end result is an int, and I couldn't see why rounding floats to round floats could lead to loss of precision
Andras: so it's something I can probably figure out, but every iteration right now, the dict is only keeping the incoming values (i.e. if I'm reading angles 100-120, then the dict is only showing 100-120) I was hoping to store all 360 degrees.
if the dict is missing those angles then those angles are missing from the input
Then create a dict/array with 360 keys?

« first day (3190 days earlier)      last day (1981 days later) »