« first day (3691 days earlier)      last day (1240 days later) » 
02:00 - 20:0020:00 - 00:00

2:53 AM
@NordineLotfi What do you mean by "the default python3 that isn't packaged by conda"? Are you on a Mac and referring to the system install /usr/bin/python (but that's Python 2 anyway)? (if that's the one you shouldn't be installing anything in it or using it for development). Otherwise, what's your OS? You have multiple Python installs. Are you using virtual envs? What's your exact issue? Have you checked your path and PYTHONPATH to see where package imports come from?
^ Anyway that is covered by lotsof existing Q&A, please skim them first.
 
 
2 hours later…
4:49 AM
cbg
 
 
2 hours later…
AAB
6:43 AM
@roganjosh thanks for replying, the site I am hosting should not really rake in more than 10-20k users. Which instance should I start with? I have currently got the 5$ instance, should I go for one with 2CPU's and 2GB shared at least?
 
 
2 hours later…
8:26 AM
cbg
 
user13415013
9:14 AM
Hi guys
 
@AAB I think the specs you've suggested are a decent starting point. You will be able to run postgres on that fine - I'm less sure about how much you'll need for the string matching features, but you can always upgrade/downgrade DigitalOcean (at least) whenever you want
 
if my code fails sometime with Exceptions from the requests and urllib3 and works without any change the next time, and fails later, all for the same data, is it ok to assume that I need to throttle the rate at which I send these requests?
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) was one such Exception
 
9:31 AM
Did you check the target's TOS on how they expect to be used?
 
its an API from wayback
but yeah let me check
maybe a dumb question, if there is no API key or such, is there really a late limit or is it really the dev's responsibility to make sure not to overload free usage? I know I can cache requests but the ones I am making now are unique
 
there is always a rate limit, whether people tell you about it or not.
Unless you pay for it, there is no obligation at all to serve your requests.
 
I guess I will have to check their docs well then, any hacks I can implement without going much into rotating proxies etc? I thought a time.sleep call would do
 
@python_learner never rotate proxies, that's being a jerk. And archive.org are doing all the gods' work.
 
laurel, I have seen web scarper devs do that, I dont want to overload their servers anyway, I will just split my data into parts and call the API at different times of the day
 
9:58 AM
Can anyone give me a link of some articles or documentation about how to male more pythonnic my code?
 
you can start with PEP8
 
thank you so much
 
@LeonardoScotti Raymond Hettinger has a nice talk on nice code: Beyond PEP8
 
Thanks
In your opinion, whats the best packages for python's GUI?
 
I think there is only one atm, tkinter?
 
10:06 AM
There some third-party GUI libraries, such as PyQt.
 
currently I'm using wxpython,
 
But my code never deals with humans.
 
because I've read that Van Rossum suggested it
 
@MisterMiyagi ?
 
10:10 AM
@LeonardoScotti The tag is for asking for close-votes. See sopython.com/wiki/cv-pls. It wasn't directed at the GUI conversation.
 
@MisterMiyagi yes i know that you are referring to something else but i didn't catch what were you sayiing
 
@python_learner yes, they are all jerks
It might come as a shock but there's a lot of bad practices on the internet
 
10:43 AM
monocle falls off face
that explains so much..
 
11:02 AM
How can i import sublìclasses from a module?
 
@LeonardoScotti just like other classes, I imagine
 
@AndrasDeak i made a mistake, i was meaning nested classes
 
Nested in other classes?
 
Obligatory question: Why nest the class at all?
 
@AndrasDeak yes
 
11:11 AM
First answer Miyagi's obligatory question. Then notice that nested classes are available as attributes, so import the enclosing class.
 
i have a module named logic and a class named PositionalLogic, and I want to import all classes and methods inside Positional logic
But from logic.PositionalLogic import * didn't work
@AndrasDeak I know that they are lke attributes but is annoying to call PositionalLogic.ANd instead of And()
 
Did you write this? If so, take up Miyagi's question. why are these classes nested inside PositionalLogic
 
Note that "import one nested class" is a warning flag, but "import all [nested] classes and methods" is as if millions of voices suddenly cried out in terror and were suddenly silenced.
 
WIthout more context, It sounds like you literally just needed a module called PositionalLogic, and made it into a class instead for some reason.
 
inside logic i have 5 o r 6 classes for different types of logic
and every class has some nested classes and functions
My question is just is it possible to do ? and if yes how? no matter the context, i know it can seem arrogant or stupid
 
11:17 AM
@LeonardoScotti This seems like a designing problem. They shouldnt be this way. Can you reorganize your code to do the same work without nested classes?
 
yes i can
so let's try this
like a miscellanous question is it possible? no matter if is stupid or unoptimal
 
You cannot do * imports from anything but modules.
 
Generally, python doesn't stop you from shooting yourself in the foot if you insist. However, you wont be able to do this with just the import statement. You'll have to import the main overarching class, and then expose each nested class/attribute yourself to the globals.
 
Python Shell, prompt 14, line 967
builtins.AttributeError: module 'logic' has no attribute '__path__'

During handling of the above exception, another exception was raised:

Traceback (most recent call last):
Python Shell, prompt 14, line 1
# Used internally for debug sandbox under external interpreter
builtins.ModuleNotFoundError: No module named 'logic.PositionalLogic'; 'logic' is not a package
Whats means this?
 
It means we need a MCVE or a MinReprEx
It also means you are well beyond the point of "don't do this".
 
11:24 AM
Or as Raymond Hettinger says, "there must be a better way" slams fist on desk
I've been on a bit of a youtube spree of his talks. They're pretty cool i must say
 
Interesting. Wasn't aware one could vote on flags for one's own messages. oO
 
That seems like an oversight
 
@ParitoshSingh Love his talks. One of the few people who I feel use the medium properly for technical issues.
 
@MisterMiyagi oof, yeah
@MisterMiyagi you can't
if you try you get a banner that tells you you can't
@LeonardoScotti it's possible if you write code for it. You can access every* class in a module, you can access every attribute of these classes, you can check if the attribute is a class. Depending on what other weird things happen in your classes this might or might not work. Have fun with it
@MisterMiyagi was this one flagged?
ah, no, it was probably the "don't do this"
 
11:41 AM
recbg
@LeonardoScotti it is possible to make this work, by a hack.
 
please don't :P
 
it is tricky to get right though.
I second with everyone else in that your design is faulty.
 
I mean if you're aware of the, umm, controversial design and their attitude, by all means
 
@AndrasDeak Both.
 
oh I just love garlic if that's what you mean :---D
 
11:44 AM
@MisterMiyagi heh
 
import types
import sys

class PositionalLogicClass:
    class Foo:
        ...

    class Bar:
        ...


def _getattr(name):
    print(f'Attempting to fetch {name}')
    return getattr(PositionalLogicClass, name)


sys.modules['logic.PositionalLogic'] = PositionalLogic = types.ModuleType('logic.PositionalLogic')

_getattr.__name__ = '__getattr__'

PositionalLogic.__path__ = None
PositionalLogic.__all__ = [i for i in PositionalLogicClass.__dict__ if i[0].isalpha()]
PositionalLogic.__getattr__ = _getattr
Python 3.8+
 
needs more asspressions
 
12:03 PM
Question: is there a way to reroute all error/log messages to my stdout if i don't have control over the actual place where the error messages are being generated?
 
yeah, you can specify a root-logger
 
For context: I'm just trying to figure out whether my tensorflow is using CPU or GPU. The problem is this: im running in a jupyter notebook launched in a different machine, and i don't have access to this machine's terminal. So, i dont quite even know how it generates the logs
    # To find out which devices your operations and tensors are assigned to
    tf.debugging.set_log_device_placement(True)
    # Create some tensors and perform an operation
    a = tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
    b = tf.constant([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])
    c = tf.matmul(a, b)

    print(c)
 
oh, it's on a different machine?
 
Yeah. according to google, this should be dumping messages: but it's dumping messages to the terminal where the jupyter notebook was launched.
 
uhm, you can set up an smtp logger and have it send you the logs by mail ¯\_(ツ)_/¯
 
12:05 PM
Is it using an actual logging.Logger?
 
Any ideas on how i can, from my jupyter notebook (that im accessing through ssh tunnels) get the messages out?
 
Just dumping it to stdout should make the notebook forward it to you.
 
Im not sure. and i'll admit i dont have a lot of understanding of how logging really works
 
@ParitoshSingh so you can access a terminal on the machine, but not the terminal the shell was started from?
 
aye. the notebook was already launched by a diff user
 
12:07 PM
So restarting it from a different shell is not an option, for instance
 
yeah, i dont want to kill this jupyter server
 
it wouldn't be surprising if you couldn't get access to a process running under another user
but I don't know anything about this
 
Yeah, im a bit out of my depth here.
 
Wait, notebooks should capture stdout. Do you see the output of print?
 
yep, print shows up just fine and nice
Actually i do suspect this isn't a python logger internally, it's quite possible the logging happens through tensorflow's C code side of things.
 
12:10 PM
I'll slowly back off in that case, then. Already killed my share of compiled apps today.
 
Some links in here that may or may not nbe helpful: stackoverflow.com/questions/46619800/…
 
@ParitoshSingh you can try setting up a local logserver, if you are connected to the notebook server via a tunnel, getting them to talk to each other might be *easy*â„¢
 
Hm, what's a logserver?
 
example for a logserver: here. there are probably easier ways to set it up, but that's the one I'm using
 
okay, let me give that a try
Looks promising, thanks!
 
12:20 PM
best of luck.
 
12:43 PM
I am trying to loop through a database and retrieve the total number of posts made (which are stored in this database). Here is my attempt dpaste.com/6X9YFV6GQ. I can get the individual posts but I am struggling to get the total number of posts. I get the error TypeError: unsupported operand type(s) for +: 'int' and 'Comment'. How can I go about it?
 
for post in posts:
    p.body
that doesn't do anything, does it?
If you just want to count how many posts there are, you'd want to increment total by 1 in the loop. Or sum(1 for post in posts). Or using len(posts) or whatever equivalent thing the DB engine offers for this purpose. (In increasing order of preference)
 
I am running it in the terminal. It gives me the results needed. I should have added print(p.body) within the for loop
 
If one post has multiple comments on it then I bet you have to retrieve that count somewhere.
 
12:57 PM
Update, i couldn't get the logs messages to show. I've since then concluded that they must be a myth, and i'm going to cross my fingers and hope im using the correct device.
This sounds like a very reasonable plan to at least one user using this machine out of all users including myself.
 
Tried this which increments total during each loop. However get an error that 'int' is not iterable

posts = Comment.query.all()
for p in len( posts):
total = total + posts[p]
 
len(posts) is an int. so, something like for p in 42 rightfully complains that you're trying to iterate over an int.
 
@GitauHarrison you are fighting hard to add a Comment object to an int, which is your original error. That's not even close to any of the things I suggested.
Are you just going to ignore my suggestions altogether?
 
I am trying them out now
 
Why now?
 
1:17 PM
@AndrasDeak This is what I have tried again dpaste.com/FYKMRJBPB I have resorted to using your suggestion of printing len(posts)
 
So it's solved?
If that's what you needed then using len(posts) is not "resorting to". It's the idiomatic and O(1) answer to your problem. Looping over your posts to count them is O(n).
It's the difference between counting your pringles one by one, and reading the label on the box to see how many pringles are in the package.
 
@AndrasDeak Yes, thank you
@AndrasDeak I will work on my Python DSA
 
there are some hints about built-in types at wiki.python.org/moin/TimeComplexity
that might help you get accommodated with rough tendencies
Of course your objects are not listed there, and they are probably not built-ins. But a loop is a loop, and len when exists should be O(1).
 
1:41 PM
@AndrasDeak thanks
 
2:00 PM
morning cabbages, folks
 
cbg
 
2:35 PM
cbg
 
Morning! I have what I'm going to now refer to as stupid data. sdata for short. I have a question about pandas with it... Anyone a pandas fan?
 
dont want to be rude, but just ask, if ppl want and can they will answer
 
That's not rude! I'm not in here often enough to remember etiquette. I should just reread the rules every time I come in so it's on me.
So
The data I have has a bunch of rows that describe the columns (35) I understand how to skip those rose to just get to the columns of data and using delimiter to parse it because it is tabs and not a csv file or an xml file.
My issues is that the first 5 columns are a description of date, time, ID, ect of the data. The next say 1000s columns (it's that ridiculous) repeat the data for "headers" 5-10 say
I'm wondering how to parse that repeating data. I've been looking through different questions asked and cannot really find what I'm looking for and have been watching several videos on the topic.
 
What exactly is your issue parsing this? Do you want to discard the repeating columns during parsing?
 
I don't want to discard any of it. I need all of the data. I'm getting confused separating the first 5 columns as date, times and that set of headers, vs separating the next repeating columns of the data.
 
2:48 PM
@Pandasncode just to be clear are you stuck reading the tsv or stuck with postprocessing?
 
I can read in the data. That's fine. I'm confused on hose to separate it all.
and my fingers are not working properly this early. hose = how to
 
separate it all?
 
I also don't get the repeating thing. Is there only one row or something? An MCVE would be most helpful.
 
^Andras'd
 
There is only one row per day/time stamps of data with increasing altitude. I'll copy one row out to a point but it is .... a lot more. one sec
 
2:51 PM
Feel free to use a code pasting service if it's too large.
 
Yes I should do that one se
 
@Pandasncode no, that's not minimal
 
This goes out to column 775 or so
 
@Pandasncode Might want to revise that link...
 
Boil it down to something small that demonstrates your issue
 
2:55 PM
@MisterMiyagi I don't understand
 
:D
 
OK, you only copied part of it
 
Yeah I only did partial
Including column descriptions
The one line should definitely illustrate how massive this thing is.
lol
 
I dont understand yet how to interpret that row. could you walk us through it?
 
@Pandasncode that's not relevant to us
 
2:56 PM
Columns 1 - 6 are just the first 6 columns of any row as a description for them.
The data then repeats the col 7 - 13 until the end of the row.
 
So there are #nlevels*k columns, each a level
And there is in fact no repetition of data
 
# Levels = number of different altitudes
 
@Pandasncode irrelevant. Talk about programming terms.
you have 6 + nlevels*k columns or something like that, right?
 
# Levels is number of sets of data from 7 - 13
 
2:59 PM
@Pandasncode I don't understand that
 
So for this line Column 6 is 105
 
2 mins ago, by Pandasncode
The data then repeats the col 7 - 13 until the end of the row.
That sounds like what I'm asking ^
 
There will be 105 "sets" of data that can be described with column 7 - 13.
 
@Pandasncode yeah
So the next row might have a different number of columns?
 
Yes it will.
The next row actually has 94
 
3:00 PM
I'd use awk to transform your file into something sane. What is your end goal?
 
AD hit the jackpot with that question. Honestly, you'd probably be better off ingesting this as strings first, and manipulating it to a proper format before throwing it to pandas
 
For this ONE file, I honestly just need the time stamp and that data exists..... so Maybe I don't need to go as far as I think I do for this specific project. But I would like to figure out how to do it for future issues too.

I think that's what I need to do too. It just sounds like too much going on on one line... I was just hoping.
I'll look up awk
 
You can also parse it in python of course. Read the file line by line, split and convert into something different
I just prefer to do my quick file preprocessing with awk which is well suited for the job
But first you must ask yourself what data structure you want to end up with. There's no obvious format you can convert to.
 
Thanks y'all.
Sorry for not being very clear to start.
 
I mean the obvious format is one new data file per original row, but that would probably be a lot of files.
 
3:05 PM
I can deal with the files.
 
I might want to end up with a dict of 2d arrays or dataframes if I were in your shoes.
but then you can construct directly that ^ by parsing directly in python manually
 
Im thinking you simply duplicate the "col 1-6" information, and make one single dataframe per file.
such that each row is 1 set of information of the entire col 1-13.
so your 1 row in file turns into 105 rows of dataframe, and so on
 
Yeah.
 
hmm today I learned that thearding.Thread and multiprocessing.Process are not just interchangeable, they have different behaviour, Process can't pass things to the main process using a class variable
 
Hi everyone, anyone here who has used t-tests a lot in his/her work using python?
I had some doubts
 
3:22 PM
@Pandasncode for the record this is the awk block that converts a single row to multiple rows with one dataset on one new row
{
    N=$6
    reps=(NF-6)/N
    for(batch=0; batch<reps; batch++){
        for(i=1; i<=6; i++){
	    printf "%s ", $i
        }
        for(j=6+batch*7+1; j<=6+batch*7+7; j++){
	    printf "%s ", $j
        }
	print ""
    }
}
N is the number of levels, reps is the number of datasets in a row. For each dataset (batch) it first prints the same first 6 columns, then the corresponding 7 dataset columns, then a newline.
having written it I'm on the opinion that you should probably do it natively in python :P
 
Lol. Thank you for this. Is this bash?
I'm honestly convinced that SOMEONE in my department is holding some scripts hostage that have already converted this file into multiple files.
I'm just tired of hunting for it.
 
Awk.
 
Hallelujah I have found it
Someone just dance with me
 
but you'd have to call it from bash in a loop
 
Almost finished adding typing information to Werkzeug. 25/32 modules done. So tired of typing.
 
3:34 PM
I hate that typing is coming more into python, the dream is dying with every day more typing gets introduced
 
I don't hate typing at all, I think it's great. I'm just tired of writing it right now, I chose one of the most complex ways to get started with it.
 
@Hakaishin It's pretty neat to have in libraries. No need to add it to your own code if you don't want to.
Wish they had added the nicer syntax earlier. :/
 
3:50 PM
@MisterMiyagi for know, it feels like a slow grab for the throne and bam, next update it's mandatory.
 
Oct 11 '16 at 17:26, by DSM
I'm on record as being willing to take good odds on the fact that the "we don't intend to make putting type declarations everywhere the new default" promise isn't worth the paper it's not printed on.
 
That's not a lot of not using of negatives.
 
it only took me a year to untangle that sentence
 
Perhaps type hints could make that easier...
 
From my own experience, I only add typing to my own code to make it easier for PyCharm to give me suggestions. Adding full coverage to library code makes it easier for everyone's IDEs. I don't get the impression that "type declarations by default" has become or is becoming a thing.
3
 
3:56 PM
xD
 
type hints affecting singledispatch is a bit scary
 
works well, though
and it's really a chore to do in the old version's that don't read the type hints.
they won't be able to do much more with that, even if just because runtime type checking even small types would be a nightmare.
 
Yeah. But until then typing was a dark mirror universe. Of course it's functools where the breach happens...
Do dataclasses also make use of type hints?
 
kind of
 
partially. Only fields with an annotation are converted to actual fields.
Fields annotated as ClassVar are not converted.
 
4:12 PM
so it sort of piggybacks on the annotation syntax, except it also uses the type info while it's at it
 
only for ClassVar and InitVar
it doesn't assert the usage of right types or anything
 
Oh, I see. So even more just syntax abuse. Thanks.
 
bingo
dataclasses do some extremely cute stuff. I read the module back when it came out, and got the feeling that 1) most of the stuff that happens in there should not be allowed, and 2) it was very easy to read and made a lot of sense
naturally, it grew on me immediately
 
It's always seemed to me like a highly intuitive but really hacky convenience tool
like numpy.mgrid
Which is great because it's 1. useful in many cases, yet 2. not grounds for pushing further design decisions, because it's really hacky
 
yeah, there are only so many hacks you can stack on top of each other while still having something that doesn't crash
good example, the 3rd party library pydantic is mostly just dataclasses with runtime assertions of the types plus custom validators. yet the inerface they offer to implement them client side is based on inheriting from their BaseClass instead of building on the @dataclass decorator
I am 99% sure it's just technically impossible to build any further on the original decorator
 
4:22 PM
:)
 
hello JDSchroeder, we can reproduce the issue, this only happened with user compile argus_camera application from the release sources. here should be mismatch between default image and public release sources, we’re still looking into it. thanks
nvidia strikes again. That is so terrifying, a mismatch between provided binaries and sources reminds me of coding machines
It's also hilariously stupid that THEY can mark answers as solved the problem, instead of like SO does it let user tell you when it's solved
 
does anyone know of a way for me to store data of different types in a postgres column? I have:
CREATE TABLE grades
(
student_number SERIAL PRIMARY KEY,
assignment_name VARCHAR(50) REFERENCES some_config_table(measurement_name)
grade (some assignments are letter grades, some are pass/fail, some are a percentage)
)
 
4:38 PM
Is that a normal thing to do?
 
I need some flexibility here, so I'm trying out this schema. Worst case, I'll have to keep everything as a varchar and cast it on the python side, which seems very suboptimal
alternatively, can I store a cast-to-this-type as a separate column?
 
For your "alternative" idea, I think that would be messy as-is. Can't you make another table of grade_type and enumerate the different types in there, then reference this table as a foreign key in grades?
You'd still have to store the grade itself as a VARCHAR with that, though. But at least you can pull grades of a single type in your query
 
a problem is that while grands A/B/C/D/F are enumerable, that's the part of this analogy that doesn't quite translate. I do have as one measurement, a freeform text (consider it a "teacher's comment on the grade"). So that won't exactly work
 
I mean enumerate the types of grade systems e.g. 1 = "Pass/Fail", 2 = "Letter" etc.
 
4:52 PM
Yeah, pretty much
 
define "suboptimal" re: casting on the python side
 
If nothing else, it's just cleaner to be able to look at the grade_type table to see all the different types rather than doing a SELECT DISTINCT on the column. You can also cleanly update the name of the grade system in a single cell in the ancillary table if you need to change the description at a later date e.g. you encounter "Pass/Fail" and then later there is a "Soft Pass/Fail" so you want to rename the original "Pass/Fail" to "Hard Pass/Fail" to be clear
 
@Kevin I'd need to query once to find the type, query a second time to get the values, and typecast in python. This seems less efficient than getting postgres to do the casting (because it can do all this in parallel without my python intervention [citation required])
 
Why would you have to query a second time?
 
fair enough, I could just join and get the value and type in ONE query. But the typecasting would still need to be done on the python side, no?
interestingly, I just found this, which seems to be my "alternatively" idea
 
5:00 PM
How are you going to process things on the Python side btw? In Pandas?
 
I'm not pulling too many rows, so just lists for now. But pandas may be the appropriate bridge to fill this gap
 
It would be the opposite because it doesn't like mixed types, which is why I was asking :)
 
hang on a sec.
my_table.my_col can have multiple types. But each query will result in all the rows having the same type in my_col. I can additionally add my_table.type and have pandas cast everything in my_col to the first entry in the query result's type column (which should be the same for all rows)
does that make sense? or have I gone insane before lunch on a Monday?
 
😂
Hi Inspector!
Cbg room.
 
Sounds like a sensible design to me
Well I'm not convinced that a query will always return rows with identical types, but other than that
 
5:06 PM
thanks for the in/sanity check, folks
o/ @Destroyer-byte!
 
😃
 
Perhaps you want to find all grades that entitle the student to a credit for the course, so you would want all rows that are PASS or C or B or A or >70%
 
yeah, my analogy could be closer to what I'm working on. Suffice to say (playing within the confines of my analogy) that I'm usually querying the grade distribution for a given assignment
and if I needed to do the "does student get credit" query, I'd have to do it in parts
 
AAB
5:20 PM
@roganjosh thanks will see what I can do...
 
Hi guys, I need some help with understanding python and how fast it can execute for loops to update arrays of data. I need to know because I have a WS2815 Addressable LED strip with 300 LEDs on it being driven from a raspberry pi. Whenever I try to iterate over all 300 indexes or even split them up into "zones" of 42 LEDs each and update the array using [begin:end], it takes longer than 33ms for the entire processing to complete. Is the adafruit python library just garbage?
 
5:45 PM
@JoshMenzel when you say "array" you really mean a python list, right?
you can time your code without the adafruit calls to see how much time is spent doing python stuff
Looping a list will probably be slower than changing sublists with a single assignment
 
@AndrasDeak yes that's correct. I'm using adafruit's neopixel library and anytime I try to do more than a fill() the strip with a solid color and break everything off into zones, it takes longer than the 33ms allotted for a 30FPS refresh rate.
I had the same thought of updating sublists with lists and I'm even using numpy to speed it up. It doesn't seem to matter if I break it up into sections and sublist each section or loop through the whole thing
 
@JoshMenzel numpy won't magically be faster. It will be faster on assignment but if adafruit doesn't know about numpy you might lose overall time converting back to lists.
I take it the LED strip and rpi hardware is definitely not the bottleneck?
I don't have any experience with this, so I'm mostly being a rubber duck
 
the strip has a maximum data rate of 800kb/s
the pi cpu is under 50%
(25-ish)
and the strip has no problems keeping up when it's asked to do just a solid color
Here's my TCPServer.py class: dpaste.org/BDYN
 
Keeping up with what? You mean you switch and it switches? But when you want it to have a moving pattern it starts falling apart?
 
@AndrasDeak yes
I'm piping in a FFT of 7 bins
over a socket(via network)
then the pi is supposed to calculate what each pixel should do and produce an animation
based on the sound(sync'd to music)
 
5:56 PM
I also take it you've isolated the part that does an animation without calculating anything heavy, and that's already where you see the slow update?
 
yes
I did a basic for loop that changed each led in a cycle of R, G, B
in a test script
and it couldn't keep up
 
no code fences here
see the code formatting guide in the room description: ctrl+k or "fixed font" button for multiline messages
 
yea I forgot, I'm used to discord
 
@JoshMenzel and that sounds minimal enough that it answers your question. If the only thing happening is stepping and changing colours then it's the library or the hardware
 
There's a github issue that has this exact problem, but it doesn't talk about a solution or what I should do code wise to fix it
 
6:03 PM
Hey! I edited a question that got closed for focus here to be more focused, any chance it can be reopened? stackoverflow.com/questions/64962080/…
 
The edits you've made don't seem to affect the fact that it's too broad, so I don't think it should be reopened right now.
 
@inspectorG4dget FWIW this is what I was suggesting
 
@roganjosh you beautiful genius, you! That's awesome. Many melons
 
6:18 PM
You're welcome :) it's not too much different yo your approach but having the names of the grade system helps with organisation if you need to add more in future or rename existing ones. You may want to add an index on the foreign key
 
mods please delete my last message thanks!
 
@AndrasDeak I'm also running the c++ version of a strand test and it's pretty slow as well.
 
6:34 PM
as requested (although I'm not a mod)
@KamrulHasan please don't ask for help here with fresh questions on the main site as per our rules
 
Okay
sorry for that.
 
it's alright :)
 
So I may have found part of the problem: The WS2815 LED strip specifications require longer reset times, resulting in a longer time to send the data
 
@davidism I see, how can I make it more specific? I'm still not sure what is broad about it
 
I don't think you're going to be able to. Check out the help center for information about writing questions that are answerable on SO.
 
6:48 PM
WS2811, WS2812, WS2812B strips require a 50us reset time while the WS2815 requires a whopping 280us reset time
 
@JoshMenzel but that's still 0.28 ms, right?
 
multiplied by 300
 
They add up for each LED? I find that surprising, but I know very little about electronics.
 
and the WS2811(the 12V equivalent for the WS2815) is really only 100 pixels since it's 3 LEDs per section instead of 1
I mean you can look up the spec sheet
it's nice and easy to read
 
I could, but it would tell me little ;)
 
6:50 PM
they even have schematics and graphs
idk
 
I'd be interested to see it :)
 
maybe I'm just using the wrong board
 
I used to have a self-installed LED strip in my kitchen, but as far as I'm concerned: it makes light
 
WS2811: https://cdn-shop.adafruit.com/datasheets/WS2811.pdf
WS2812B: https://cdn-shop.adafruit.com/datasheets/WS2812B.pdf
WS2815: http://www.witop-tech.com/wp-content/uploads/2017/06/WS2815-12v-addressable-led-chip-specification-.pdf
The source video that explains some of this when working on an arduino: youtube.com/watch?v=VAa4duqMrgs
I even used the rpi_ws281x c++ module and it can only do about 30FPS(there's a test executable that you can run to make sure everything "works")
and that's without any socket receiving and processing of audio data
 
I'm trying to work out whether there's any cross-over with the types of things I was doing with modbus. Chance of me being able to help ~1%, but I'm generally curious anyway. It'll just take reading on my part
 
6:57 PM
I mean the whole project I want to do is to build a 1d music visualizer across all 300 pixels and have it run at 125fps(8ms for all processing to be complete)
 
7:18 PM
@davidism I see, is there a way I can get help with this problem, even if not through stack overflow? Do you think you could still help me or point me to someone who could?
 
7:34 PM
do you guys know what algorithm would solve this? - given a bunch of people each from a different department (engineering, sales, admin etc) pair them with each other but do it so no two people from the same department are paired together. I was trying to find somethign similar in places like hackerrank etc but wasn't able to
 
@JoshMenzel Changing a single pixel on a neopixel forces the device to redraw (= 2400 bits). You have to compute the whole bitstream foir the image so the hardware can just clock-shift it through the device, which then changes state when the transfer is complete (citation needed).
The NeoPixel is specifically recommended for microcontrollers rather that interrupt-driven machines with complex operating systems. But that's about the limit of my rather theoretical NeoPixel knowledge.
Using it as a led-addressable device is a no-hoper, I suspect.
Unless you keep your own copy of the image and have a driver that can blit it out to the device.
@erotavlas Have you researched "partitioning problems"? That might get you something (no promises).
 
@erotavlas I'm thinking something like: find the department with the most unpaired people, and the department with the second most. pair as many of them as possible. Repeat until done.
This can still fail if no solution exists, for example if you have 1 person in HR and 999 people in R&D. No promises about whether it will definitely find a solution if a solution exists
 
and it would not prefer large-scale intermixing
Perhaps one could take the largest group, and pair each person from there with other groups in a round-robin way. If the largest group runs out, take what remains of the second largest.
there might be number theoretical reasons why this would leave you with a few people in the same group eventually... but perhaps some pairs could be easily shifted around with people from the largest or next largest group?
Then again this would still mean that the smallest groups are likely to be paired with the largest group.
 
Hmm, think I found a counterexample for my proposal. For an input of 10 HR, 95 R&D, 99 admin, it first creates 95 admin/R&D pairs, then 4 admin/HR pairs, then it has 6 people left in HR that can't be paired. One possible solution is 92 admin/R&D, 3 HR/R&D, 7 HR/admin
 
But for 3 groups of 2N size each, you'd get N (1-2) pairs, N (1-3) pairs and N (2-3) pairs.
I'd love to be nerd sniped by this but I'm already behind schedule with my work :'(
 
7:54 PM
I was thinking to just have a list (department) of list of people, iterating over the department list, pop person from current department and one from next department, and then move to the next department and do the same, keep going
 
I suspect that will fail for the same reason mine will
If my math is right, for exactly three departments, there's exactly one solution. For departments A B and C, the number of A/B pairs = (A+B-C)/2
Checks out for my sample case
 
02:00 - 20:0020:00 - 00:00

« first day (3691 days earlier)      last day (1240 days later) »