« first day (3444 days earlier)      last day (1503 days later) » 

12:11 AM
i needed a long break from macos - i have had it... so I'm back on linux for a while
 
wim
12:57 AM
^ PyCon 2020
 
can't say that it comes as a shock
 
AMC
@Todd What's going on with your macOS installation?
 
I haven't been able to adjust the annoyance factor in the settings =/
I keep looking for that setting to try and turn it down, but can't seem to locate it
 
you have to buy it for $999
 
ughhh.. i'm about to =(
 
AMC
1:13 AM
Lmao
What are you trying to do?
 
wim
1:34 AM
Linux and macOS are about equally annoying, what's the problem?
 
2:02 AM
Nothing that can be solved. I just don't like the UI interfaces to their tools and utilities.
I'd disagree about macos and linux being as annoying.. Linux doesn't make me want to clobber my screen.
linux - tons of documentation when things go wrong.. macos.. sorting through searches for hours just to find one little thing.
 
someone know how to hide the line printed in vscode before activating the venv?
Lab> & c:/Users/AmericaN/Desktop/Lab/env/Scripts/Activate.ps1
(env) Lab>
 
wim
2:25 AM
probably easiest just to make new venv (when you create the venv you can customize the prompt)
 
3:18 AM
sku_lists = {
    "Roller": ["DR1", "DR2", "DR3", "DR4"],
    "Dust Mask": ["DM1", "DM2", "DM3", "DM4A", "DM5A"]
}

categories = { sku: category for category, sku_list in sku_lists.items() for sku in sku_list }
Anyone have a reference regarding categories = { sku: category for category, sku_list in sku_lists.items() for sku in sku_list } I had my friend help me with simplifying my code and created this. Although I don't have a clue where category came from
Doesn't seem to be defined anywhere in my code
But it works
 
 
1 hour later…
4:40 AM
@Pherdindy category is just a key in the dictionary which the code is looping on . you can think of it like : for key,value in sku_list_dictionary.items()
where category is the key and sku_list is the value in the dictionary
 
 
2 hours later…
6:38 AM
@anky_91 Hi, do you have any idea what's wrong with my Python Code?
 
Where is your code? Is this a continuation of some other discussion?
 
@roganjosh you're up early ;)
 
Couldn't sleep. Milk for brews running low, which is causing anxiety that can only be solved by making a brew. It's a terrible trap :/
 
ugh... I hear ya
 
Still, I'm relishing the one I have :)
 
6:48 AM
I'm going to try and force myself to get back to sleep... Saturday is pretty much my only day off ever, so normally use it to get some shut eye in... ideally... wouldn't even have been awake until midday... but stupid old me just wakes up at 5am every day whether I like it or not it seems
 
Sounds like a plan. Sleep well mate
 
[22:25:31] [Server thread/INFO]: WillDodge was blown up by Creeper
[22:38:28] [Server thread/INFO]: WillDodge was shot by Skeleton
[22:40:32] [Server thread/INFO]: WillDodge burned to death
[22:45:48] [Server thread/INFO]: WillDodge was shot by Skeleton
...
[00:35:18] [Server thread/INFO]: WillDodge has made the advancement [Acquire Hardware]
[00:38:11] [Server thread/INFO]: WillDodge has made the advancement [Isn't It Iron Pick]
[00:44:30] [Server thread/INFO]: WillDodge was slain by Zombie
[01:25:59] [Server thread/INFO]: WillDodge has made the advancement [Suit Up]
 
Umm look at the last paragraph: stackoverflow.com/questions/60785192/…
 
@Dodge you're doing reasonably okay then? :p
 
willdodge isn't great at dodging
 
6:58 AM
Rough night for Will lol
 
@Todd heck they're doing better than me... I walked into a creeper in the first minute and then got killed by a zombie 20 or so seconds later while trying to fiddle with the video settings :)
 
@anky_91 thanks
 
what game is it
 
minecraft - it's on the star board >>>>>
 
it's interesting that a game that looks blocky like that has such a following
i dont think I have enough debotated wam to play it though
 
7:07 AM
Anyway... I'm going to rhubarb for now... no doubt be around later :p
@roganjosh on a side note before I go... I've got some log files from a client regarding what routes they did pick for a few days, so I'll (not today) extract the orders from the system that corresponds to those days so there's a base reference and then work from there I guess
 
Hi folks, can anyone here help me out with my python code?
 
@JonClements oo. That will be really useful for benchmarking, thanks
@DarkRunner as I asked earlier. Where is the code? Please see the room rules; it is suggested that you just ask your question, with an MCVE, and people are more than happy to help if they feel able to
 
7:22 AM
Here's the code:
[Link Below]
@roganjosh Better yet, here's the link: colab.research.google.com/drive/…
 
@DarkRunner I assume you didn't read the room rules because you'd see that long blocks of code should be hosted off-site
 
Sorry, I'll delete that @roganjosh Thanks for letting me know
 
Thanks :)
What is your question?
 
So basically the purpose of my python code is to break up North America into pieces. It's actually called a Voronoi Diagram of North America.
The final result should be something like:
The problem is that when I run the code, there's an error telling me '''ValueError: Cannot transform naive geometries. Please set a crs on the object first.''', which basically means the two maps don't have the same scale/shape/etc.
But I don't know why; The code has cities = cities.to_crs(na.crs) for that reason
If anyone can help that would be great
 
Ah ok, I've seen that at the bottom. It's not something I think I can help with myself, sorry, but maybe some others can. It's quite specialised, though, so it could take some time for people to respond
 
7:28 AM
can you please provide the first and last part of the traceback? then we at least know what happened where
oh, nvm, it's in the notebook
 
Yeah, everything should be in the Google Colab Page
@roganjosh np thanks
 
is there a reason why you call cities.geometry.to_crs(epsg=3857) and throw away the result?
 
I'm not sure; at the end, I set cities' crs to na so that they have the same scale
So either way, it shouldn't matter, right?
Yeah, I just commented it out and that has no effect on the error
 
I'm just wondering whether you have to store the result somewhere
not sure though, never used geopandas myself
 
ok, in the meantime I'll post a Q
 
7:37 AM
@DarkRunner since that was the line that threw the error, which other line throws the error now?
@DarkRunner please be aware that for a Q on SO, you should include all relevant code in the question itself. Links might as well not exist.
just in before countless bored WFH people downvote you relentlessly....
I think this part of the docs are relevant for your problem.
Basically Python doesn't know what initial CRS your data has, so it cannot transform the data to another.
 
quick question here
 
TLDR: you have to set cities.crs first
 
* I have a class named InstaOps
* this has a method get_meta
* can I write a method inside InstaOps Class that will create another instance of the Class
 
yes. You can directly refer to the class by name, or declare a classmethod which also works with inheritance.
 
Ohh ok let me try that
 
7:46 AM
class V2:
    def __init__(self, x, y):
        self.x, self.y = x, y
    def copy(self):
        return V2(self.x, self.y)
        #        ^ or use `type(self)` instead of `V2`
    @classmethod
    def zero(cls):
         return cls(0, 0)
 
reason: this class has a few args that can help me change the nature of the instance --- say Incognito mode
what I want to do is write a method that will be under this class but is capable of creating Class INstannce with diff prop i.e incognito mode
@MisterMiyagi when Class del is called it will only kill the particular instance right?
because I am also terminating my DB conn in del
 
@MisterMiyagi yeah, same error
 
as for your DB question: yes, __del__ is only called for the instance collected. No, if you close the DB connection and haven't copied it properly, other instances using this connection will also lose it.
 
could you suggest a workaround please
 
@DarkRunner see my last message to you. The problem is that the cities data doesn't have an initial CRS.
@Aqua4 not with the few information you have provided.
since you imply that many instances share the same DB connection, is there only one connection per process?
 
7:52 AM
@MisterMiyagi So apparently the following resolved the error, but now it says my tuple index is out of range
 
def __del__(self):
    """
    chcek if smart_activity has been started
    if yes - check if session info has been stored
    """
    if not self.incognito:
        self._store_session_info()
    self.db_conn.commit()
    self.db_conn.close()
    self.text_to_speech("Shutting Down Bot", False)
    self.driver.quit()
    if not self.incognito:
        self.text_to_speech(
            "Bot has been powered off, goodbye {}".format(self.user_name), False)
 
So that resolved the crs error, but now it says IndexError: tuple index out of range;
 
no, I am creating db_conn only once in the init , and the killing it when destructor is called
so lets say 1 db connection engine (sqlite) per instance
 
then everything is fine.
note however that __del__ is not a reliable way to clean up, only a last resort. Consider explicit close methods or context managers.
 
@MisterMiyagi doc ref please. this would certainly improve my coding standards
@MisterMiyagi so creating another instance inside my Class method should work fine right?
 
7:58 AM
@MisterMiyagi i adjusted my code as suggested by the documentation, but now I have a IndexError: tuple index out of range error
 
See Python Data Model: __del__ for gotchas of using __del__ for cleanup. See Python Data Model: With Statement Context Managers (and its links) for creating context managers.
@DarkRunner yes, I read that the first time you wrote it.
@DarkRunner Did you check whether coords and na_shape are as you expect them? E.g. not empty, and I guess they should be of same size?
 
haha @MisterMiyagi seems to be stretched out thin.. lemme experiment and get back to you later
 
@MisterMiyagi I just did print(coords) and print(na_shape) and I got
I'm really confused
 
I guess so. Now imagine you haven't written the code yourself, have no idea what the data looks like, or how the libraries work. ;)
We can only guide you to finding the error yourself.
Either way, that's something to start searching from, isn't it?
is cities.geometry empty as well?
 
8:16 AM
looks like it
Anyway, thanks for trying
 
You might want to check whether the cities CSR actually is EPSG:3857. Sure, it silences the error, but it might very well put the cities someplace... else.
 
8:31 AM
fresh cbg everyone
 
 
2 hours later…
10:56 AM
A question for @roganjosh and others: things like Can Python be used to create multiplayer browser-based games? are usually closed as offtopic for SO (this one was 'needs to be more focused'), but we should tell users to go to GameDev.SE, agreed?
 
In terms of the recommendation to the OP, I'm not sure I would want to push that particular kind of content over there because I dont have a feel for what they would welcome; they may deem it too broad, too
That's not to say that I think your suggestion to the OP was incorrect, just that I'm not confident that I'd actively support it myself. It's pretty open-ended I guess
 
11:19 AM
@smci I don't know if that question is roughly on topic there in particular, but the rule of thumb is "don't migrate crap". So 1. only suggest an alternative site if the question is well-written but otherwise off-topic, 2. always explicitly tell the user to make sure that their question is on topic on the target site, possibly by also linking to the corresponding help/on-topic page.
so this is just general guidance for this kind of situation
 
@AndrasDeak It's broad but it isn't crap. And there are many other more specific such questions. I was looking for language and framework recommendations and I found the answers helpful.
 
Broad is a grey area I guess, because it's hard to tell how that would be received on the target site (since broadness is very much a culture-dependent thing).
 
@AndrasDeak Can always recommend the OP to make it more specific. Graphics-intensive or 3D games, and mobile games, are a separate category. I was looking for the more basic ones.
 
Yeah. I was mostly talking about trying to figure out a priori if it's worth suggesting to ask elsewhere
 
I might as well ask you all here: for a multiplayer browser-based boardgame adaptation which is not graphics-intensive/CPU-intensive, not 3D, what language and package do you recommend, both for client and server? node.js on the client presumably? and what on the server? Not PyGame I think. (And yes I already googled it for 8+ hours. I'm looking for real developer experiences from any of you). I want to draw a (static) gameboard, move pieces, etc.
 
11:32 AM
@Pherdindy :)
 
 
3 hours later…
2:28 PM
Ugh, the OP went on to make it an obvious dupe by answering as an edit in the question. I wasn't confident to vote otherwise
 
Yeah
 
For users of VSCode; is there a simple way of getting formatting to work for a HTML file with <script> tags containing JS? It's getting confused and I would have thought this was reasonably common (or am I committing sins?). This issue got closed as needing more info but I thought this would be common sense
Other than this issue, it's made my workflow much easier in every aspect, other than dipping back to Spyder for the Ipython console :)
 
oh you'll love this then, you can get ipython in vscode
they've literally patched my only big complaint i had with it just 2 days ago or so
 
Oh really??
 
select some code and press shift+enter
im not a 100% sure if that works out of the box or not
basically, vscode added support for jupyter notebooks. and this was a side effect :P
 
2:38 PM
Oh, that's awesome. I'll have to update when I can since I downloaded this in Jan I think. I'm struggling at the moment to remember that things are in tabs now and I dont have to keep jumping between editors for front-end and back-end :)
 
yeah, the interactive side of things used to end up giving you a horizontal scroll instead of behaving like they did in spyder. This has been fixed couple days back
I think vscode is trying really hard to replace spyder for me.
 
Once I get more comfortable with it, I imagine I can run the Flask dev server in it too, because i had that running the node server with continuous integration when I was playing with React
@AndrasDeak OP has asked me a question that I'm really not sure how to answer. Is there value in their suggestion?
 
3:32 PM
@roganjosh meh
 
Kinda my thoughts too. Thanks
 
@JonClements Haha, yes. I now understand why the game is so popular. It has been a nice distraction. Thanks.
 
 
1 hour later…
user11297480
5:02 PM
  train1 = pd.read_csv('train.csv', iterator=True, chunksize=150_000, dtype={'acoustic_data': np.int16, 'time_to_failure': np.float64})
 
user11297480
in this statement what does chunksize=150_000 mean?
 
you can either read a whole csv file at once, or pandas allows you to read it piece by piece
That specifies the number of rows you're reading at a time, when reading it piece by piece. Or in chunks
 
user11297480
chunksize=150_000 is 150 separated with underscore 000 ..what the underscore specifies ?
 
5:18 PM
wait, you're working on the earthquake dataset aren't you
this just rang a bell.
kaggle.
 
user11297480
yes
 
cool, that was a good one
 
5:33 PM
I've never really understood the underscore syntax for powers of 10. Is it a culturally-neutral syntax to get around the fact that some people use . and others , for separators?
Oh, there's a PEP for it
Oops, now I've just seen Andras' link. I was being slow it seems, sorry
 
5:59 PM
@roganjosh also the "only" unambiguous way. x = 10,000 is a tuple
 
Yeah, I only considered that after reading the PEP. You could also pass a string but then it really would his the issues with the way different people represent decimals. Ok, it all checks out for me now :)
 
@roganjosh In writing, a space as separator is customary. So 10_000 is 10 000, just like feed_dog is feed dog.
 
@MisterMiyagi I would never write it with a space, though. I would definitely write 10,000 and just lived with no separator for coding
 
6:17 PM
Hi, how do I solve the error: local variable 'screen' referenced before assignment?

I have a line ship=Ship(ai_settings, screen)

Before this line I wrote self.screen = screen ,
bbut it didn't solve the problem.
 
@roganjosh I'm used to it from LaTeX and sciency stuff. Apparently, someone declared it a standard as well.
 
That makes sense for unambiguity
 
@MisterMiyagi oh, the standard is interesting. I guess that it avoids the cultural ambiguity I mentioned. It would take me some real effort to do that in written work :)
 
6:36 PM
old_key = min(self.lru.keys(), key=lambda k:self.lru[k])
the self.lru.keys() will return the keys in the dict
how does the lambda function work? where does it take the k from?
 
@YoelZajac could you please prepare an mcve?
k is a parameter. the lambda function by itself doesn't do a thing. min however, takes that function, and applies it on each item one by one
lambda is just a function. you pass it things explicitly when calling a function
 
@ParitoshSingh so min can take a set of keys
then pass it to the 2nd argument
 
no. min can take an iterable (sure, set of keys), and apply the function on each item in the iterable one by one.
 
ok
 
@YoelZajac please see the formatting guide. Also, that snippet would be better posted on some site like paste and linked here
 
6:47 PM
ok
 
@YoelZajac rule of thumb: if there is a scroll bar, the code snippet isn't short enough.
 
ok thanks.
 
AMC
Hello all. I thought I would mention that I'm still looking for feedback on my attempt/draft of a canonical/reference answer for the classic "trying to scrape dynamically generated content using requests (or similar tools)". You can find it here.
I'm still uncertain as to how much I should cover in the answer, for example.
 
 Is there a way to pass `{}` as a fstring in python? Am I missing anything..
    ''.join([f"(.{i})" for i in [1,2,3,4]])
    # '(.1)(.2)(.3)(.4)'
    #expected: '(.{1})(.{2})(.{3})(.{4})'
 
@anky_91 double the character to escape it. E.g. ''.join([f"(.{{{i}}})" for i in [1,2,3,4]])
 
@MisterMiyagi Nice i was literally escaping it by backslash arghhh... Thanks :)
 
note that this is the same behaviour as that of str.format
 
7:13 PM
@AndrasDeak Sure , i was unaware that you need a double char in such instances , Thanks for the heads up :)
 
7:25 PM
@JonClements this project has been great for passing the day. Merrily tip-tapping away and just been smacked with the "oh yeah, GDPR, and I'm not actually on a contract" realisation attached to a brick. My system can work solely on order numbers but it raises an interesting question of how to comply if I have customer details even for a short while
The simplest, I guess, is just to allow them to upload a spreadsheet of order refs and columns of customer data, and just map everything together and throw the run sheet back out, storing nothing. If nothing else, it's raised some interesting learning points :)
 
@roganjosh I thought GDPR was an EU thing ;)
 
@AndrasDeak <lobs the realisation-brick back at The Channel>Away with you, EU! Shoo! :P (sorry for double ping, I couldn't resist the extra rhyme)
 
7:42 PM
@roganjosh great news, I resolved my error! It only took a few hours
Pretty awesome
But, now I want to find the number of cells in the diagram
How can I do that?
If anyone can help that would be great
 
@DarkRunner very glad for you, the output looks great :) Sorry that I wasn't able to help, I'm not familiar with the library and didn't have time to research it
 
get a sharpie, and check them off on the computer screen while you tally them
 
thanks
@Todd Not the best way I'm afraid
 
oh =( not a scalable solution?
 
Not a scrollable solution :(
 
7:56 PM
rofl Todd
number of cells in diagram..is that number of distinct regions?
if so, im sure that you have that data somewhere already available , it had to be used while rendering this map i assume
 
8:30 PM
@ParitoshSingh I rendered the map using geovoronoi
I'm not aware of any method to determine the # cells in a diagram
 
Number of voronoi cells = number of input points, yes? Surely you have that.
 
oh wow
 
8:54 PM
whats the difference between
class LRUCache:
and
class LRUCache(self):
 
There's a 99.99999999% chance of the 2nd one being incorrect because that's inheriting from self
 
where do you need to be the self 's then in the classes?
 
ugh
@Permian Can we please not do this every time you think of something? Read a tutorial about defining classes.
 
ok ok
 
8:58 PM
Yup, these are definitely you-need-a-tutorial level questions
 
i acutally thought it was a nuance of the language
which i had discovered
 
 
2 hours later…
10:30 PM
that's an interesting one - inheriting from self...
 
wim
10:47 PM
gonna order an ergo keyboard + mouse for WFH, any recommendations?
 
personally i use logitech mx 3 mouse .
 
wim
I have the sculpt at work actually
might try that logitech k860
 
i think that WFH will not be for a long time. you just need anything to pass this time. so don't pay much
as it's will be in the obsolete after that :D
 
Why would it be obsolete?
 
Ops, that's in case if you separate work time than home time.
something like in work i use that. but in home. just laptop keyboard enough
 
11:03 PM
alright, strange question: i find myself in a situation where using the metaclass features of type would be useful. what i'd ultimately like to do is, if i write "from .script import fluffy" in some file
i want fluffy.py to generate the class "fluffy"
i know how to generate classes alright. what i DON'T know is how to trigger this generation on import
would someone mind pointing me to the right direction?
 
like, "if a file imports [X] from this file, generate class [X]"
kk, i'll read through that~
@αԋɱҽԃαмєяιcαη sorry, i'm not really sure how this article was relevant to my question :l
did you link the right one?
 
Nor am I. But what do you mean by "generating" a class on import?
 
are you looking to create object from class in separate file ?
 
so, let's say i have a list of strings in "file.py" that will ultimately be classes. say:
class Name(some_base_class):
    model_name = "Name"
names = ["jon", "mike", "linda"]
i would like, for examle—in another file, to be able to say something like
from file import mike
and get, effectively, an object of:
class mike(some_base_class):
    model_name = "mike"
so, if i were in the same file, i'd use
type(f"{names[0]}", some_base_class, {"model_name": f"names[0]"})
and this would generate the appropriate "mike" class
 
11:17 PM
Something looks really wonky about both approaches to me
 
what looks wonky?
i did not, in fact, solve my problem haha
i am not sure how to trigger the creation of that class on import though
 
Please edit the other message. I had a panic that autocorrect messed up "wonky" :P
 
oops, haha.
that first approach isn't real code (it was just a stupid illustration of what i want)
the approach that uses "type" is really how that class would be generated
i am just not sure how to do it on import. like:

"if this file is imported, and whatever file is importing it wants "mike", then generate the "mike" class and return it" or something
 
Hmm, i got it in wrong direction then. i thought you are asking about garbage collection from class
 
might have to create a class loader that automates the process @AmagicalFishy or module loader
 
11:21 PM
But that makes a bizarre API, no? Wouldn't you want instances of a class and attributes relevant to the particular instance?
I can't say I've come across the setup you've suggested. It reminds me of "variable number of variables" but I could be wrong
 
yes. ultimately i'd like to return an instance of said class
but i figure if i can get what i mentioned done, returning an instance (instead of the class itself) will be trivial
 
Hardly, if you dont even know what class names exist
 
maybe importlib is something to look at
 
i mean, i'll know what class names exist :p
oooh, i'll check out importlib that's a good idea
 
yup
you can hook into the import machinery that way
 
11:24 PM
suuuuuper good idea. i totally forgot about that library. thank you. :)
 
yer welcome
 
How? What classes are in the namespace? You're creating them dynamically and letting them roam free? What am I missing here?
 
i'll give you some context, @roganjosh :
my testing is getting a little bulky. i'm using "factory" to generate a lot of various model factories (for some sqlalchemy stuff). what presented this problem is the fact that like 90% of the code to set up a model factory class is the same for every model
so i have a lot of
class ModelNameFactory(factory.alchemy.SQLAlchemyModelFactory)
    model = ModelName
    sql_alchemy_session = db.session
    sql_alchemy_session_persistence = "commit"
    ... # Maybe 1 - 2 model-specific attributes
 
wim
You could do that using module __getattr__
 
11:28 PM
I then use these factories in my tests for... well, whatever i'm testing at the time
that code i just posted is duplicated like 15 times at this point
i think it'd be a lot nicer to just have a list of models, and, when one of my tests imports "modelnamefactory", an instance will be generated and given to said test
i think i'm going to set up an importer. :) (what might i use module__getattr__ for, @wim?)
 
wim
# factories.py

types = {}

def __getattr__(name):
    if name not in types:
        types[name] = type(name, (), {})
    return types[name]
now from factories import MyFactory will dynamically generate a type, if it wasn't already generated
 
That's an interesting approach
defining __getattr__(name): at the base in a module. cool idea. python 3.7 feature.
 
11:46 PM
@wim dude what that is awesome
 

« first day (3444 days earlier)      last day (1503 days later) »