« first day (3838 days earlier)      last day (1093 days later) » 

user15638707
1:11 AM
Hello!
 
@CoolUser2819 that's too much code and formatted badly. Please post it to a code paste site and link here.
 
user15638707
sounds good
 
for shorter messages you'd have to review our code formatting guide to chat because chat markdown is silly
 
user15638707
o I'm trying to figure out this simple? Thing and I don't want to make a post about it
 
user15638707
1:16 AM
how do i go down a line
 
user15638707
without hitting enter
 
shift enter, mostly
 
user15638707
I can't believe I never knew that
 
but all non-code/non-quote markdown will break in multiline messages
 
user15638707
So I'm trying to figure out this simple? Thing and I don't want to make a post about it.
Code: pastebin.com/raw/n6crS9sC
 Basically it only outputs the first 4 lines, if I change the number 4 to something else like 5 it only outputs two lines, so basically how do I make it output all lines.
 
1:23 AM
It doesn't seem like it should do "first 4 lines". Seems like it should do "every fourth line starting from the second"
It's not clear to me what the code should be doing so I can't tell you how to fix it.
I'd separate the two steps: first figure out what dict structure you need to get the desired yaml in the end, and then figure out how to build that dict structure.
 
user15638707
It does what I need it to
 
user15638707
the structure works fine, I just need it to parse every line
 
user15638707
Is there a way I can just say "parse lines until none left"?
 
user15638707
1:38 AM
(I have been looking that up not just asking cause im lazy)
 
1:59 AM
hello all
 
hello
 
i just have small q .. where i can find guide for django allauth ( i want add style to forms ) the problem is allauth have many codes i don't know how to add style and boostrap
 
@john please don't ask for help here with fresh questions on the main site as per our rules
 
okay so where i can ask
 
that is not specified in our rules
 
2:09 AM
okay thnkss
 
 
2 hours later…
3:49 AM
Hi Guys....I have a long issue I wanted help with....can I upload the question anywhere here?
I have an issue I uploaded at stackoverflow.com/questions/62785042/… help me with this
 
 
2 hours later…
5:47 AM
@R.Islam that is a long time to wait, you can try to bounty it if you reputation allows, also editing a smaller version of that csv might help people run your code
 
 
1 hour later…
6:57 AM
Hi guys, I have an issue with the argument parser.
https://stackoverflow.com/questions/67153592/filenotfounderror-winerror-2-the-system-cannot-find-the-file-specified-but-pa
 
7:11 AM
@JosipJuros - room rules ask that you not dupe post recent questions here. I did add a comment on your question though.
 
7:35 AM
@Aran-Fey since most people never have to replace __new__, The Man wanted to avoid having Little Bob peek into The Abyss. Getting hooked on metaprogramming is not for the faint of heart.
morning cbg, by the way
 
8:25 AM
What does windows use for the subprocess lib as executable?
 
@JosipJuros Again, please keep discussions on your recent questions restricted to the main site. Duplicating/splitting discussion here will just make it more difficult to help you and others.
 
I'll give you a hint: Look at the source code
 
 
1 hour later…
10:02 AM
SyntaxError: 'return' with value in async generator D:
So, my "async yield from" plans have become both simpler and insanely more difficult at the same time.
 
10:17 AM
Huh. Isn't return x equivalent to raise StopIteration(x)? Why on earth would that not be allowed in an async generator?
 
I guess it comes down to return only making sense alongside yield from, so they did not bother. :/
I'm somewhat peeved that PEP-525: Async Generators explicitly contradicts the reasoning of PEP-380: yield from: "to compose asynchronous generators a simple async for loop can be used"
 
10:32 AM
quick question, though this might annoy someone who actually knows their stats. if i run a ttest link I should look at the p_value, and when the value is very low, i should conclude my samples are different, yes?
 
@MisterMiyagi being consistent has never been python's strength
 
the core of python has been decently consistent, you've just been looking at the ugly parts too long :P
 
@Aran-Fey Probably wouldn't hurt to at least try... ;)
@ParitoshSingh yes. Now all you need to do is figure out what "very low" actually means in your case.
 
perfect, thanks Miyagi
 
have a jelly bean on the house
 
 
1 hour later…
11:52 AM
cbg
how's it going, hope everybody had a great weekend
 
12:39 PM
An interesting optimization problem I've run into in a game I'm playing: you have an NxM checkerboard, and want to fill each tile with a copper mine or a beacon. copper mines are worth ten points, and each beacon boosts the value of any adjacent mine (both orthogonal and diagonal) by 40%. Multiple beacons stack additively, so a mine surrounded by 8 beacons is boosted 8*40%=320%. Some tiles are already occupied by obstacles, and nothing can be placed on them.
 
cbg-ning
 
Here's an example board, with my lazily-optimized solution. Blue squares are beacons, red beakers are mines. The game is "NGU Industries" BTW FYI
I think you can get pretty far just by filling the board with mines, then iteratively searching for the tile with the most neighboring mines, and putting a beacon on that tile. But I suspect that doesn't give you the one true maximal solution.
For practical purposes it's more than enough to get within 10% of true optimality, but that's no fun
 
Oh dang, I just realized this is even harder than I thought
I was gonna say you should place a beacon on every square that's adjacent to at least 3 mines, but that's not true
 
Hmm, I also thought that, but now that you mention it...
Placing a beacon on a square that's adjacent to at least three mines, and which is not itself already boosted, is a strict improvement, because you lose 100 points and gain 120. But if the square under consideration is already being boosted at least once, you're losing 140 points to gain 120.
And even using the strict improvement variant may lead you to a local maxima
At least this insight improves my greedy best-tile-to-replace-finder by a smidgen
I'm trying to decide if this problem could possibly be NP hard. Games like this are often proven NP hard by showing how you can construct objects analogous to wires and logic gates, and then you're done, because circuits are NP hard via the 3SAT problem.
 
1:24 PM
I'd watch out with that north eastern corner
 
place some beacons there and power him up
 
@AndrasDeak maybe it's friendly and can offer advice... (that or it's responsible for the south eastern corner...) umm...
 
since my brain can't handle thinking through this, i'd say first order of business could be bruteforcing your way to the best solution(s) and then use that to verify all more reasonable approaches
 
Here is a simple testing framework that takes care of loading the map into an NxM list-of-lists, and scoring and displaying etc etc
I see my hill climber is 12% better than simply using only mines, which establishes something of a ballpark for how high we can get
More sophisticated approaches will almost certainly not meet my arbitrary 10% cutoff point for being worth the effort
Oops, that map doesn't match the screenshot because I missed a row. One second...
@ParitoshSingh Certainly, I'm quite keen to brute force the solution if it takes <24 hours. But... The most direct algorithm would be to try all combinations of mines and beacons, and there are 2^122 of those.
 
1:49 PM
Well, you know a beacon is never worth placing on a tile with less than 3 neighbors, so it's more like... 2^118?
 
Let's see... My script says there are 121 empty tiles with 3+ empty neighbors. Uhh, that's definitely not right, because the southwest island should bring it down to 119 by itself. Is my iter_neighbors buggy? Please hold...
Nope, just a typo in the map again. v1.2
There are six empty tiles that are 100% guaranteed to be an inefficient spot for a beacon: the 3 tile southwest island, the center tile of the eastern bridge, the top right corner of the southeast continent, and the easternmost peninsula.
Bringing us down from 2^132 to a mere 2^126 combinations
 
2:06 PM
guys i have a csv delimited by ; for some reason when reading the data into a pandas df with df = pd.read_csv("asociaciones-valencianas-2021.csv", header=None, names=[
'COD_NUM_AUTONOMICO',
'DESC_AMBITO',
'DESC_DENOMINACION',
'DOMICILIO',
'MUNICIPIO',
'DISTRITO_POSTAL',
'DESC_AUTONOMIA',
'SITUACION',
'FECHA_INSCRIPCION',
'FECHA_ULTIMA_SITUACION',]) the info is thrown all into first column... how could i prevent this?
 
setting the sep/delimiter should get you a long way towards the desired goal...
 
2:21 PM
greedily choosing the replacements with the biggest score change first gives me another 10%+ gain over the simple hill climber... Still within the realm of practicality, much to my surprise.
 
@MisterMiyagi have done this still seems to be importing wrongly
 
results in:
MMMM
BBBB
MMMM
MBMB
 
@Kwsswart That's the point at which an MCVE would come in handy.
 
So that is the best arrangement of just mines and beacons with no obstacles on a 4 x 4 board
 
Hmm, I would not have guessed that there would be an asymmetrical solution. Makes sense though.
 
2:25 PM
essentially I have dpaste.com/C5TWEM95D with which i have the same column 'COD_NUM_AUTONOMICO' which i would like to merge on to create another df and from that a new csv
 
The 2x2 case trivially has four asymmetrical solutions, for example
 
Trying 5 x 5 /crossfingers
 
I think that one will be symmetrical. I feel it in my water.
For 5x5, hill_climb_biggest_first gives me ["MMMMM", "BBBBB", "MMMMM", "BBBBB", "MMMMM"]. Basically what I would go for if I was optimizing manually.
 
hmm 2 ** 25 is a lot to iterate over with calculate_score /-: Its still running
 
Try async
 
2:31 PM
would jquery help in this case?
 
Ya'll joke, but combination bruteforcing is quite parallelizable, so you could get a NUM_CORES multiplier to your performance.
Not that going from 2^25 to 2^23 is necessarily the solution to your problems. But such is the way of things.
 
@Kevin why are mines beakers?
@Kevin if this were a continuous problem I'd have long suggested scipy.optimize.differential_evolution and friends
I never know what to do with diophantine problems. Goes to show that discrete math is silly.
 
In the real game, there are multiple kinds of tiles that produce and consume resources. The beakers are "Red Science Juice", which are made from cardboard and glue. Cardboard is made from cardboard ore, which is extracted from the cardboard mines. Likewise for glue.
 
Hmm...
 
I was too lazy to put down mine tiles instead of science juice tiles before taking a screenshot.
 
2:36 PM
I see, then I get it
 
@AndrasDeak Yes, integers were a bad idea, who invented them anyway
 
"lazily-optimized" was lazier than I expected
 
Don't give me no guff about tickmarks made on bones to count livestock, you know those cavemen could easily make a half tickmark if they had a very small cow.
 
@Kevin ... it seems i've yet to learn how quickly these things grow out of hand. jeebus
 
Hi, first time here, I just discover the little button left to "logout". What it is used for ?
 
2:48 PM
@DorianTurba probably for logging out
 
Haha
no I mean, Chat
 
do you have a screenshot?
 
I use a lot discord to chat with other devs
 
are you asking what chat (like this room) is used for?
 
and just discover it exit a place to talk in SO
 
2:49 PM
This one?
 
@ParitoshSingh yes, in general
 
@ParitoshSingh oh you're right
 
Looks suspicious... Better not touch it
 
you know... i now realise i dont even know where my logout button is. haha
 
@Kevin XD
 
2:50 PM
oh that helps :P
 
HAha
 
"chat" is French for "cat" so most likely that section of the site is for cats only
 
just like every section of the site, since cats rule humans
 
Yeah I know, don't you see my pp ?
I'm a cat disguise in human
look the evil eyes
Those chat room are use to talk about what in general ? discuss about some hard question, the life of python around the world, etc ?
 
@ParitoshSingh Yeah, it's pretty big. I'm still open to the idea that the total possibility space can be reduced with some kind of clever scheme
@DorianTurba Pretty much. Most recently we've been talking about a possibly NP-Hard optimization problem that I have
 
2:52 PM
@Kevin i've got a couple thoughts. each independent island can be solved separately for example. and then, each node that only has two valid adjacent nodes should always be set to a mine
upto 2 valid adjacent nodes i should say
 
Yes, I agree with both. That solves about 15 tiles for us.
 
@DorianTurba it's a bit of a mixed bag, each room can have their own rules and policies. Ours is linked (here)[sopython.com/chatroom]
 
That leads me to wonder if it would also be possible to divide and conquer the segments of the mainland... You could slice out the northeast section, for example, drawing a border through the three bridges that connect it to the other sections. For the ~7 tiles adjacent to the border, find all 2^7 combinations of layouts, and solve the rest of the map for each of them.
 
i was trying to think of that, but the boundaries are a bit annoying to reason about
 
2:56 PM
@ParitoshSingh oh yes sorry
 
That could, in principle, get you down to 2^7 * (2^ 90ish + 2^ 30ish), which is quite nice
 
i suppose it would be close to very efficient even if we fudged the boundaries
 
If you get very unlucky with your choice of segment slices, I suspect it's about as efficient as regular combination brute forcing. But I wonder if it makes it easier to memoize intermediary results... We might be able to take advantage of the fact that score for a tile is solely dependent on itself an its immediate neighbors.
 
aye
haha
the more i think of this, im convinced this has to be np-hard
my theory is, i could have multiple states of solved "ideal" layouts, and causing 1 shift could let me ripple through the entire board for no actual gains
 
I'm like 75% sure it's NP hard. I would be truly delighted to see a thorough proof
 
3:08 PM
well, i might not be sure about the np-hard, but im sure about the hard part :P
 
"Rippling through the board" is exactly how many tile based games are proven to be equivalent to an electric circuit that poses a 3SAT problem
Simulating an electrical pulse down a wire gets you 90% of the way there
The other 90% is implementing XOR gates ;-)
 
gosh, being vindicated by Kevin makes me feel smart, even if i have no clue what is going on. i'll take it :)
 
3:40 PM
That's a good feeling to have. Smartness plus cluelessness is a fertile environment for new ideas.
I don't know where I'm going, but my rocket tricycle will get me there in style
 
speaking of rocket tricycles, I've been wondering if doing Dijkstra would be reasonable here
 
I don't immediately see how I could make this into a graph problem of less-than-astronomical size, but then again I've only considered it for the time it took me to write this sentence
 
It is astronomical, but the adjacency is very local. You can generate neighbour states by replacing each tile with its complement. What I have in mind is an educated BFS that protrudes into high-score directions
Directed brute force, if you will.
 
You all have seen me write "Hmm, actually" enough times to know that sometimes understanding percolates out of my subconscious at the speed of treacle
 
but it would be a fair amount of effort for something that might not help anything
 
3:53 PM
"very local adjacency" jives quite well with the caching idea I was kicking around with Paritosh
 
I like the idea of directed brute force. Heuristics are pretty awesome. Take the number of adjacent mines, beacons, and empty tiles, do some random math with it, and boom, your algorithm magically processes the tiles in near-perfect order
I call this approach "just guess correctly, bro"
 
A beacon will boost somewhere between 0 and 8 mines, therefore the average number of boosts per beacon in an optimal solution is exactly 4
(Which actually makes it unsuitable for this other optimization problem I haven't mentioned yet, involving MegaBeacons that give a 10x boost, but only to mines that have at least 5 MegaBeacons surrounding it. I am not making this up.)
 
these nerdsnipe honeypot games are getting out of hand
 
Please do not optimize the MegaBeacon, if you talk to me about it I will not read your message
There, now you have no social incentive to be nerdsniped
 
So at least 5 MegaBeacons, you say?
 
4:05 PM
Uh,,, <_< No, a MegaBeacon actually doesn't boost anything, and it produces the same amount as a normal mine. The only benefit is it has racing stripes that make it look cooler
The only thing you can optimize for is coolness, which is fairly elementary
 
hehe
 
4:24 PM
cbg
 
wow, I spent WAY!!! too long on projecteuler.net/problem=96
 
Sudokus are surprisingly hard to brute force
 
for anybody here familiar with structlog, I was trying to just wrap a standard python logger (what my coworkers are use to working with) into structlog using wrap_logger and then turn it into an async logger (using AsyncBoundLogger). So far trying to make AsyncBoundLogger use the wrapper_class arg didnt work and when I tried seeing if the wrap_logger output can be used to initialize AsyncBoundLogger I got an error about the constructor also requiring a context
 
You'd think the uniqueness rules would trim the possibility tree, but it's not enough
 
which admittedly I still dont quite understand based off what I've read in the docs (maybe just read the wrong sections but I'd say they're not that good on it from what I've read)
what has worked (without the async stuff):
logging = wrap_logger(
    baselogging.getLogger(__name__),wrapper_class=AsyncBoundLogger(
    processors=[
        filter_by_level,
        add_log_level,
        add_timestamp,
        JSONRenderer(indent=1, sort_keys=True)
    ]),
)
 
4:40 PM
I have an idea for a mine/beacon brute forcer that makes optimal use of existing cached information. It essentially uses a flood fill over the board, choosing a final value for each tile once it is no longer on the edge of the fill. In principle, it could run in O(2^F) time, where F is the maximum perimeter of the flood fill's wavefront. So there is high incentive to fill the field while minimizing the wavefront size.
 
where baselogging is the python logging class aliased to baselogging ( import logging as baselogging )
 
But that, too, may be NP Hard ;_;
Ok I'll be quiet now and let Skyler have the stage
 
I can post a larger mvce but there are a fair bit of imports and some configuring before that, gets to about 20 lines
which i think is a bit longer then you guys like having posted here
 
I'm always happy to get a not-so-minimal CVE in a pastebin (or equivalent) :-) although admittedly I don't know much about structlogging.
 
oops, actually I posted the not running one, the running one is:
logging = wrap_logger(
    baselogging.getLogger(__name__),
    processors=[
        filter_by_level,
        add_log_level,
        add_timestamp,
        JSONRenderer(indent=1, sort_keys=True)
    ],
)
 
4:44 PM
The worst that will happen is, you'll post a link to your rather big code, we'll think "hmm, that's rather big, I don't think I can tackle this one", and we go about our day
 
ill try to thin it out a little but, but as i take a second to try and thin it out mainly I'm just trying to figure out how to use structlogs async logging abilities so I'm open to other angles of attack
import datetime, sys
import logging as baselogging
from pathlib import Path
from structlog import wrap_logger
from structlog.processors import JSONRenderer
from structlog.stdlib import filter_by_level,add_log_level,AsyncBoundLogger

baselogging.basicConfig(filename = 'tmp', format="%(message)s",level=baselogging.DEBUG)
logging = wrap_logger(
    baselogging.getLogger(__name__),
    processors=[
        filter_by_level,
        add_log_level,
        JSONRenderer(indent=1, sort_keys=True)
    ],
that should probably work, removed some custom functions and simplified configs a bit
 
As I suspected, I'm not too familiar, but I'll play around with it nonetheless
 
I tried doing something like AsyncBoundLogger(wrap_logger(...)) but it complains about needing a 'Context' additionally in the constructor. And there is a flag you can set in wrap_logger called wrapper_class which in the api docs says:

wrapper_class – Class to use for wrapping loggers instead of structlog.BoundLogger. See Standard Library Logging, Twisted, and Custom Wrappers.
doing this though:
logging = wrap_logger(
    baselogging.getLogger(__name__),
    processors=[
        filter_by_level,
        add_log_level,
        add_timestamp,
        JSONRenderer(indent=1, sort_keys=True)
    ],
    wrapper_class=AsyncBoundLogger
)
led to an error when I ran the logs: `<ipython-input-16-6b026bc22810>:1: RuntimeWarning: coroutine 'AsyncBoundLogger.info' was never awaited
logging.info("This is a test log")
RuntimeWarning: Enable tracemalloc to get the object allocation traceback`
 
Isn't that exactly what you'd expect from an async logger?
 
4:59 PM
what do you mean
 
The whole point of an async logger is that its methods return coroutines, no? So you have to do await logging.info(...)
 
hmmm
is there anyway to get around needing to modify every line with logging.info() though. Was hoping on making this very easy to just plug in at the config log step
so that people just basically import a file, wrap their previous logger, and then no other changes would need to be made
I'd say that some projects here go to the point of overlogging so I'm also additionally worried that the structlog rendering overhead can be a bit of an issue in some of the loops people run (hence why I started looking into shoving it off into its own thread/asynchronous execution)
is this some wishful thinking on my part
 
5:23 PM
I'm sure it would be possible to spin up your own async event handler, and wrap your AsyncLogger with an async resynchronizing logger, which will manage the handler for you. And then your users won't have to await anything themselves. But if you do that I don't think there's much point in having an async layer to begin with.
Perhaps I'm misunderstanding what an AsyncBoundLogger actually does. I will read the docs. Until stated otherwise, assume that I'm dimwitted yet well-meaning, and weight my advice accordingly
 
Yeah, async seems like the wrong tool for the job
Offloading the work of writing text into the log file to another thread/process is definitely possible, but I doubt it's worth the effort
 
It might be worthwhile if the logging is I/O bound, but I suspect this usually isn't the case
Maybe if you're json.dumping some extra big data structures that you already have available...
I'm imagining an engineer at google explaining some process to the intern: "this is the logging server, all it does is while True: logging.log([get_page_rank(page) for page in the_entire_internet])"
The very heart and soul of the search engine. Make sure to put a fresh "do not unplug!" sticky note above the outlet every Thursday, because otherwise the cleaning lady will use it for her vacuum
 
5:44 PM
Hmm, I was hoping I'd be able to test my flood fill algorithm on paper, but O(2^F) is kind of a pain even for F=5 and secret constant multiplier C=4
 
6:02 PM
Bleh, I'm stumped. I've got a blazing fast algorithm that achieves a score of 17800 (compared to Kevin's 18080), but I can't seem to make it perform any better than that
 
Try removing cost_of_becoming_skynet = 1000000000, sometimes that helps for me
 
6:27 PM
Five more elifs to make it a deep neural network
 
Alright, I give up. Simulating possible candidates beats educated guessing... for now
 
6:43 PM
cabbage
 
6:59 PM
A fine addition to my collection
 
cbg all, bugrit.
 
7:15 PM
Ah, while looking for ideas for my problem, I came upon a tangentially related concept I was previously searching for: Universal Traversal Sequences
TLDR: for any regular graph, you can always construct a sequence of instructions (along the lines of "take the Nth edge belonging to this node"), and following it will ensure you set foot on every node in the graph at least once. The instructions work no matter what node you start from.
 
neat
 
I was pretty confident that there was an XKCD comic about this, or perhaps SMBC or Doghouse Diaries or one of those sciencey guys, but I don't see any fun illustrations in google's images tab
slidetodoc.com/… at least has a stick man in a funny hat, which has lowered the brow enough for me to get the gist of it. It seems like there's no constructive proof for actually finding the sequence. At least not one you can fit on a slide in 14 point Comic Sans
 
the wiki page did suspiciously contain the word "probabilistic"
 
7:32 PM
I think that corresponds to the "biting a slice of cheese" slide about 2/3rds of the way down the page
ctrl-f for "fails to cover it with probability" if you're interested
This only covers the proof for graphs with only 3 edges per node. I assume the proof for N edges is a similar methodology but with harder math
 
the rest of the owl
 
Yes precisely
 
I can do N=2, the rest should be straightforward extensions
 
Well hang on, you need two points for a good extrapolation. I'll do N=1. You don't mind if I get primary author credit, do you?
 
you'll be the first as the person who wrote the paper, I'll be the last as the head of the research team
I'm not even sure N=2 is that trivial, but I'm also not even sure what kind of methods we're talking about (no time to actually open the slide)
 
7:47 PM
Hmm, I see what you mean
 
fyi you can use convolve2d to calcualate score
from scipy.signal import convolve2d
import numpy as np

def parse(raw):
    return [[*s] for s in map(str.strip, raw.splitlines())]

def calculate_score_(board):

    ones = np.ones((3, 3), int) * 40
    conv_b = convolve2d(board == BEACON, ones, 'same') + 100
    mines = (board == MINE) * conv_b
    return mines.sum()

b = np.array(parse(raw_board))

print(calculate_score(b) == calculate_score_(b))
%timeit calculate_score_(b)
%timeit calculate_score(b)

# True
# 31.3 µs ± 78.7 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
 
Python and all library maintainers beware: twitter.com/pyblogsal/status/1384187176758374404
 
Chilling
 
8:10 PM
backlash soon when people start to note that it's not nice to make fun of people who are probably mentally ill
 
Depends on the mentally ill person's level of power. Weak mentally ill people: backlash. Powerful mentally ill people: not so much.
 
9:06 PM
I don't think that was Andras' point (but I may be wrong). In any case, I have no idea what I just read
 
I'm starting to think that google translate might be a more likely candidate
 
The response does seem rather strong, though. Google may have been having an off-day and just used the most extreme versions of every translation it could think of :)
"I'm going to write to the PSF" --> "They're coming to break your door down and take you in to the Galactic Court". Cromulent.
 
 
1 hour later…
10:20 PM
@PaulMcG "the python program company" must be mustering legal team
 

« first day (3838 days earlier)      last day (1093 days later) »