« first day (3167 days earlier)      last day (2006 days later) » 
00:00 - 18:0018:00 - 00:00

00:38
@JonClements re:this, not sure if you're aware but I found some time last night and finished it (link). Let me know if there's anything you think it's missing. AFAIK I covered all the bases except performance which I might get to at some point but I don't think is too important given performance comparisons can only be made in the context of regex replacement.
01:03
cbg
@cs95 Wow replying a comment 8 days ago?
yes, and?
01:27
rbrb
 
3 hours later…
04:02
Hi everyone, anybody here?
04:22
cbg
I am here RaphX
05:16
rbrb
No one chatting today
it's great that we have you to always break the silence.
05:39
yes, thanks @U9-Forward :)
06:20
Cabbage y'all
cbg
Hey @Arne, long time no see :)
yeah, it's been a while =)
welcome back to lurking with the finest cabbage on the SE network
Thank you - I've missed you too. :)
Earthquake in Chengdu last night - 6 on Richter scale...
Interesting part is that people received a 20 seconds advanced warning, with a countdown on tv, etc...
I believe this is a first
China invested millions to test this early warning system; they seem to have some good results here.
06:43
@ReblochonMasque Oh you are in Chengdu, but it seems that you say you're in Ningbo
Yes, I am in Ningbo, not Chengdu. "I was told..."
@ReblochonMasque Oh, i saw your SO profile and your location is Ningbo
Yes, NingBo, south of Shanghai.
nice, been to shanghai and suzhou last november, beautiful place
06:53
Yes they are @DeveshKumarSingh
yes, I assume you are an expat
Sort of; it depends where you look at if from - I see myself as a foreign resident, but that's quite a thin distinction.
yes, seeing your name is french sounding and you live in china, I sorta guessed
07:09
Hey everyone
I am new in this group
potato @ReblochonMasque
haha, banana, melon. you?
Laurel
banana, melon
07:20
cabbage cabbage
@AhsanKamal do you need asparagus?
right now carrot
but soon because I am start ML and trying to build a recommendation system
rbrb
Rhubarb
07:36
Laurel
08:13
rbrb
09:06
the OP says he has duplicates, which the answer in the dupe does not cover
duplicate doesn't address duplicates, how meta
09:22
@MisterMiyagi Oops. I just hammered it. But we can add better targets.
I also added links to some questions about finding the longest consecutive subsequences. I quite like the technique using groupby that Moses illustrates: stackoverflow.com/a/44392621/4014959
09:35
Wondering if there is a coding guide for bash scripts. I found the google guide but nothing standard
bash is picky for whitespace so there's much less wiggle room. Also bash scripts are typically much shorter than full-blown programs in other languages, so I wouldn't be surprised if there's none.
Mine is like 53 lines long, I did run it through shellcheck.net and found one issue which I fixed
Perhaps I will install shellcheck and try it out
@DeveshKumarSingh Give me a minute...
the only reliable rule I have found is "don't"
any shell script we've actively maintained over the years was worth replacing at some point with another language
@DeveshKumarSingh mywiki.wooledge.org/BashGuide This guide aims to aid people interested in learning to work with BASH. It aspires to teach good practice techniques for using BASH, and writing simple scripts.
09:43
@MisterMiyagi I use shell scripts for some basic things, like interacting with dockers which are fully command line oriented, and combine those with ansible
we did something similar for Puppet
in our case, all that stuff is either Ruby now or a liability
if it is complex enough to require a style guide, it is too complex for bash
@PM2Ring Thanks although would you mind if I show my script to you and you could perhaps take a look :)
And of course, browsing the answers by the high-rep users on U&L can be very useful. Some of the Python regulars like chepner are also Bash experts.
yes whatever I achieved in my script was all thanks to U&L, we also have triplee here who is a bash gold badger too :)
@DeveshKumarSingh Ah, yes. triplee is good too. :) No disrespect intended by not mentioning him earlier.
Jan 17 '15 at 13:46, by PM 2Ring
Stéphane Chazelas is a regular on U&L. He's the guy who discovered the Shellshock bug in bash last year. His knowledge is vast. And he has the interesting habit of improving other people's answers so that their code handles obscure corner cases and is more portable, and then upvotes them. :)
09:52
thanks @PM2Ring I will hold off on bash questions now, given this is a python room
@DeveshKumarSingh Yeah, ok, although my Bash is a bit rusty. I've barely used it in the last year, so I may not be very competent at analyzing your script. But I guess if it passes shellcheck, and it appears to perform correctly, it should be ok. And I should be able to spot if you're doing anything dumb. :)
@DeveshKumarSingh That's probably a good idea, but paste a link to your script, if you want. Or maybe ask a question on Code Review.
@PM2Ring Thanks here it is dpaste.com/0GY15VR Sorry I don't know many people using bash, and the bash room appears pretty inactive The script takes a list of A=B arguments where env var A is set to B and A is checked if it is in an allowed list of names as well
10:04
@DeveshKumarSingh That looks mostly ok to me, but triplee, Antti, or Wim may have some advice. You have a couple of places where you forgot to use double-quotes on parameter expansions.
The basic rule of thumb is that you should double-quote every expansion. This prevents unwanted word splitting and globbing. When in doubt, quote it. From mywiki.wooledge.org/Quotes#When_Should_You_Quote.3F
10:17
@DeveshKumarSingh you know what we tell people that ask here about non-python because the other room is not active?
the bash room does seem half-dead but tripleee posted there 5 hours before you asked thre
I'd wait a day to see if they get around to seeing your question
yes, and I have posted my query there as well
aah okay cool
eh, I wouldn't like a room-to-room move from the other side
especially with a single out-of-context message :P
@AndrasDeak I'll give it some context.
thanks
10:29
Lunchtime cbg. Been a while. Mostly been deep in the murky world of infrastructure and whatnot the last while, rather than python :(
10:42
Correct me if I am wrong but the relationship between an iterable and an iterator is that iterable is a container which gives an iterator using which one can iterate over the contents of the iterable, where a list, dict, range, file handle etc are such iterables
pragmatically speaking yes
layman terms, that sounds good enough
Yes, I think the missing part was you call iter on the iterable to get the iterator, and then call next on the iterator to get the contents?
@DeveshKumarSingh Very close. But not all iterables are containers. Eg, generators are iterables.
iterable and iterables are abstract concepts that do not necessarily map to container and content
10:48
So we can have iterables that can be iterated over indefinitely.
import random

def randoms():
    while True:
        yield random.random()
strictly speaking, you just have the relations for iter(:Iterable[T]) -> Iterator[T] and __next__(:Iterator[T]) -> T
After MisterMiyagi's code, if we do thing = randoms(), then thing is an iterable.
okay, got it, I was going through this and they mentioned containers
@MisterMiyagi Yes that sounds more concrete I think
@DeveshKumarSingh "As said, most containers are also iterable. But many more things are iterable as well."
@PM2Ring got it containers are a subset of iterables
10:53
erm...
actually, they are not
you can have non-iterable containers (uncommon in Python) and containers are more than just an iterable
@MisterMiyagi Okay I didn't knew about those, do you have any examples for the same
containers have a length and allow direct access, which iterables by themselves do not
as for non-iterable containers, one has to explicitly make a container non-iterable, so that is pretty uncommon
@DeveshKumarSingh Sure. A simple class with a bunch of attributes "contains" those attributes, but you don't have a simple way of iterating over them.
@MisterMiyagi thanks, that clarifies containers are more than just an iterable part
hm, Generics are technically speaking containers that are not iterable
10:58
Of course, you can iterate over an instance's .__dict__... unless the class uses __slots__
Okay, I have read about Generics in Java, where you can have a list of objects, or a map between objects and lists
an Iterable is a generic, it "contains" Iterable[T]s such as Iterable[int], but you cannot iterate over all possible T's
I am frustrated by a code. can I contract the code out for modification for a fee? taking up too much of my time cos I can't get a handle on it or just tired
but, again, that is really uncommon as a container usually knows its keys
@MisterMiyagi Is iter(:Iterable[T]) -> Iterator[T]how python grammar defines it, or it's just a convenient way to put the point across
11:02
I don't know if that is allowed
@Starter Perhaps you can. But not in this room.
okay
just tired
@Starter Sorry about that. We just don't want to get spammed by job offers in here. So we have a general rule about it.
@DeveshKumarSingh Python "defines" it as iter(iterable) -> iterator
but __iter__ could format your hard drive and snort coke for all that Python cares
using type annotations, that's how iter looks though, yes
@MisterMiyagi okay, type annotations got it
11:08
@PM2Ring where do I go for that then
any freelancers website where you can advertise your requirement
@PM2Ring Thanks for moving my message there, I got great inputs from triplee :)
@DeveshKumarSingh you can have a look at typeshed if you want to see the type signatures for builtins and the stdlib
okay thanks @PM2Ring
@MisterMiyagi thanks! Look like that file has list of all type annotations
typeshed is used by most type checkers and IDEs for type hints of the things that ship with Python directly
11:30
Hello everyone I have a numpy array of shape (40000, 48). I want to calculate the entropy on the second dimension for each entry of the first dimension. My output shape should be an array of shape (40000,) where each entry contain the entropy of the 48-dimensional array
How can I do it in a vectorial way?
I can also use Pytorch
11:50
@francescop which entropy?
If the rows of the array are probabilities of a distribution then the von Neumann entropy would be something like -(np.log(arr)*arr).sum(axis=1)
just find a concrete definition of the entropy you want and compute it with a column-wise sum
Is there a way to build struct sequences?
>>> import sys
>>> type(sys.flags)(1,2,3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: cannot create 'sys.flags' instances
class flags(builtins.tuple)
may I ask why you'd want that?
overwriting flags during runtime
a completely safe and sane thing to do, I am sure
12:05
> Struct sequences expose an interface similar to named tuple in that elements can be accessed either by index or as an attribute. However, they do not have any of the named tuple methods like _make() or _asdict().
I suspect it's safeish to monkeypatch them with a namedtuple
That's what I wanted to try next, but then I'd have to figure out how to parse a struct sequence's attributes
from the docs it seems that they only have to be tuples and allow attribute lookup
@Arne don't you have to do that anyway?
even if you could instantiate an object like that you'd have to populate the fields, because they're immutable
if I could use flag's constructor, I'd imagine passing in the arguments in the right order would bind the right names automatically.
ah, I see
the only way to get them is, from what I see from what dir(flags) gives me, parsing it's repr
which is ok I guess
12:10
you're just too far down the path to hell to see how that's not OK
:p
this is awesome:
>>> sys.flags.__new__(type(sys.flags))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: tuple.__new__(sys.flags) is not safe, use sys.flags.__new__()
@AndrasDeak Shannon
each entry is a probability distribution of size 48
i have 40000 of them
>>> set(dir(sys.flags)) - set(dir(tuple))
{'inspect', 'optimize', 'no_site', 'dont_write_bytecode', 'ignore_environment', 'n_fields', 'no_user_site', 'n_sequence_fields', 'verbose', 'dev_mode', 'hash_randomization', 'n_unnamed_fields', 'debug', 'interactive', 'utf8_mode', 'isolated', 'quiet', 'bytes_warning'}
>>> len(set(dir(sys.flags)) - set(dir(tuple)))
18
>>> sys.flags.n_fields
15
The 3 additional attributes are probably n_fields, n_unnamed_fields, n_sequence_fields.
@francescop then what I wrote should probably work, give or take a log2 and watching out for exact zeros in the distribution.
There's scipy.stats.entropy but it doesn't support an axis kwarg.
Ye thanks, I could use pytorch
12:22
> Wow! You finished the last level, great! (ノ^_^)ノ (ノ^_^)ノ (ノ^_^)ノ
@Kevin \o/
Finally I can remove the hat of shame. The pronged barbs make this thing really hard to sleep in.
Did you git gud?
You can never become truly gud, it's like trying to run to the horizon.
Unresolved topics:
- merge conflicts
- staging
- all the advice from yesterday I got that I replied to with "I'll think about this"
In particular chat.stackoverflow.com/transcript/6?m=46525558#46525558 and chat.stackoverflow.com/transcript/6?m=46525478#46525478. Perhaps the problem is that I'm still thinking in terms of single-user repositories.
I suggesr fabricating a toy repo to see how these things work out
I wanted to do that yesterday for rebase vs merge but forgot
12:30
@AndrasDeak how is that a contest? rebase >> merge
read yesterday's transcript :P
thanks a lot for the attribute set snipped btw
No problem
"When you have to rebase your branches onto [local] master it's so that you can merge only your new change into [remote] master after" is a pretty good description of my problem from two days ago. My bugfix branch was one commit ahead of master, but 3000 commits behind origin/master. I could have rebased bugFix onto origin/master and then pushed to the remote master
Glad to hear that :)
12:32
The resulting PR would appear as if I had never bungled anything in my local environment
Although maybe it would have been fine to just submit the PR with bugfix still being a child of the year old commit... There was no merge conflict, so the outcome would have been the same, except the commit tree would look a little weirder.
cbg for a bit
@Kevin depending on how their CI is set up you can get very arcane errors, it's usually better to rebase onto a fresh master if your patch is horribly out of date
34 users here, this is really the time to talk :P
And we are
@Arne he ended up doing a git tutorial for exactly that reason
12:38
Cabbage Reblochon.
Now I can submit PRs with the confidence that I'll only embarrass myself with my bad code, not with my bad source control discipline.
Yikes my internet is very bad today. Great time for everyone else to post stuff without fear of being kevin'd.
@Kevin First time i heard users use "kevin'd", well you talking to yourself :P my internet is bad these days as well
@AndrasDeak omg haha lol that's the funniest thing i've seen in python :P
This is when python fails...
13:08
cbg cbg
Time to work on the task that I was putting off by learning git: resolving merge conflicts in the non-git source control we use at work.
Kevin carefully lays out in front of him versions final_v2 through final_v3b_new_final
That's the most productive form of procrastination I've ever heard of, ha!
13:49
The ol' "avoid working on the extremely important thing by instead working on the moderately important thing"
It doesn't work for me most of the time. My monkey hindbrain knows I'm trying to trick it into being productive.
@cs95 well done.
It's hard to fool because it has access to the crystal ball that I use to determine the true intentions of OPs.
Thanks, @piR. I imagine all the downvotes on the question are from people who've not read "It's OK to Ask and Answer your own Questions".
Whenever I get a sense that I'm beginning to understand human behavior, I focus on up/down votes to remind me that I never will.
The last time I posted a self-answered question, I preemptively added a comment linking to that post. Ultimately I got more upvotes than downvotes, but who knows if the comment had any effect.
13:58
I've seen that, and noticed somebody recently flagged and had it removed. Apparently these are off topic now 🙄
user10984358
14:09
heya
user10984358
can anyone here tell me if I can somehow save a model I trained on Google Colab?
user10984358
I mean is there a way I can take the trained model and run in my local machine
@Kevin alternatively you can git checkout master then git pull then git checkout bugFix and git rebase master. The end result for bugFix will be the same as rebasing onto origin/master and master will be up to date for the next feature branch you need to create.
@Code-Apprentice so many needless steps
You can and should just work with upstream/master (or origin, whatever)
Personally, I like to keep my local master up to date
14:18
@Code-Apprentice I too tell my master everything.
14:28
@TheNamesAlc using what? (torch, tensorflow, etc)?
if torch I know you can just mount the drive
from google.colab import drive
drive.mount('/some/path/to/gdrive')
torch.save(some_model.state_dict(), path)
for tensorflow do the same but use Saver instead of state_dict: saver = tf.train.Saver() then saver.save(foo, path_and_filename)
...actually you could just directly use model.save(path_and_filename) with the mounted drive with tf depending on how you trained your model
also cbg all
@JGreenwell have you checked out TensorFlow 2?
it's still in beta but it is a lot more userfriendly compared to TF 1 because of Eager
nope and probably won't until the one company I use TF with migrates (or at least looks at migrating which will be a while yet)
I'm just happy I got them off Python 2 at this point :).....very, very happy about that
3
they've made keras the standard from 2 onwards, you'd have to go out of your way to avoid it now. There's also no concept of placeholders or sessions (since everything is executed eagerly)
debugging models will finally become a lot less painful
There's some reasons to convince your boss ;)
14:44
yeah, in a year I'll start looking at migrating (legacy, long process, other priorities right now) - not saying your wrong just have a bit before that hits the "soon" part of my project roadmap (its in future right now)
15:03
I wasn't paying attention to TF. Thx @cs95. I'll integrate TF2.0 in my next ML project
I was wondering, is it oké to make an off-topic remark to a user which has asked some really basic question the last couple of days. The remark would be that he should spend some time learning the basics of Python first before he dives into pandas.
Sounds exactly on topic to me.
Oke thanks.
15:19
I use google calendar twice a year and of course it's down exactly when I need it... guess I'll miss my exams ¯\_(ツ)_/¯
I guess he just reads what he wants to see, I give up @piRSquared stackoverflow.com/questions/56652029/…
@Erfan you can lead a horse to water ...
user10984358
@JGreenwell using Tensorflow, I will check that snippet, it is still training, can I also use the same method you said in case I want to train it again from the point where I stopped??
@Aran-Fey don't you guys have an official online system?
We do have some kind of calendar thingy, but I don't trust it. Most of our systems are a huge mess, especially for a university of technology
they straight up deleted my email account, for example. No clue why. Gonna have to contact them about it once exams are over...
15:46
@TheNamesAlc use keras.models.load_model() method to re-load it (or might be able to avoid that and just load directly with TF2)
yeah, taking flack for downvoting a question that asks "how can I do X in Python?" with no effort (which has 7 upvotes & 5 answers & is on HNQ)
@Aran-Fey wow
the question really reminds me of a task I used to use when TAing Data Warehousing and DSS courses - the names are even the same. I wonder if that professor is still using the same question and needs a heads up >;\
16:14
Hi everyone
I again need help understanding a codeforces problem
Please don't solve the problem
Just help me understand the third test case
I want to know why its 10 instead of 12
@piRSquared thanks for all the suggestions. Seems people prefer the unstack version, performance caveats and all :P
Keep the faith (-: You know very well that you can't determine anything useful from a poll of 2 vs 3
@RaphX How would you get 12? The maximum I see is deleting 2 5 times in a row, which gives a score of 10
@RaphX Can you describe the steps you took to get twelve points? Here's the choices I made to get 10:
1 2 1 3 2 2 2 2 3
  ^
  |
pick this one. Total points: 2. Delete that element and all elements equal to 1 and 3.

2 2 2 2
^
|
pick this one. Total points: 4. Delete that element and all elements equal to 1 and 3.

2 2 2
^
|
pick this one. Total points: 6. Delete that element and all elements equal to 1 and 3.

2 2
^
|
pick this one. Total points: 8. Delete that element and all elements equal to 1 and 3.

2
^
|
pick this one. Total points: 10. Delete that element and all elements equal to 1 and 3.
true that
16:22
I however would have left a comment on the stack answer rather than posting a new answer (-:
First I am picking a 3 which means deleting a 2 and a 4(which is not there)
Repeating the same thing again to get 6 points
Then I am picking 3 2's deleting 1s or 3s to get 6 more points
You don't really understand how it feels to have your thunder stolen until someone does it to you. After that it's a matter of whether you have that etiquette or not
Some (thankfully) do. Most do not.
@RaphX You have to delete all 2s, not just one
Ok I got it @Aran-Fey
Thanks!
16:38
Currently in hour 4 of trying to get this Java GUI to consistently recognize double clicks
@Kevin gone bald or grey yet doing so :p
I'm looking in the mirror but I can't tell if I have any gray hairs. I can only see red right now.
Ask again when my beserker rage ends.
I suggested a dupe for the HNQ that JGreenwell linked, what do you think? stackoverflow.com/questions/56641935/…
can't claim it's a 100% match, but come on
Out of curiosity, what GUI framework are you using?
and I'm sure I've seen a similar and new one at most a few months ago, but I can't find it
16:41
@Aran-Fey swing.
So not JavaFX. Good choice, probably.
For the morbidly curious, Detect multple double-clicks/Reset MouseEvent? has approximately the same problem as me - rapid-fire clicking isn't considered multiple consecutive double clicks.
I have two possible solutions ready to go, I'm just annoyed that there isn't an idiomatic bulletproof single-line solution that does exactly what I want.
@AndrasDeak I've added an answer on the target, if it wasn't a 100% match before, it is now
@Kevin "When is a double click not a double click?", asks the Sphinx
@cs95 OK, thanks
16:53
Just hammered
"What creature single clicks in the morning, double clicks in the afternoon, and triple clicks in the evening?" The answer is "man".
oh, marking as a duplicate removes it from HNQ too (which is becoming a great resource for finding questions which need hold/closed status)
hmm...what double-clicks anywhere in the JPanel or on a specific object
In the morning, you haven't had your coffee, so you can only feebly click to browse your email. In the afternoon you're properly caffeinated, so you can do productive work. In the evening, you play StarCraft and your APM reaches its maximum for the day.
17:11
hahaha
at least it's not the master branch
wtf? I'm getting TypeError: is_registered() missing 1 required positional argument: 'model' on a line of code in django: self.has_registered_model = admin_site.is_registered(self.model). Clearly there is a positional argument here...
well, that error was a complete red herring and completely unuseful...although, I understand why now.
Maybe it needs a second positional argument.
admin_site was a class, not an instance?
I had self.inline = MyInline(MyModel, AdminSite). So admin_site was the class...not an instance
so really, I was missing self...
/me awards himself 5 quatloos
17:15
I award myself one "technically not wrong" pat on the back
Aran-Fey figured it out ;-)
17:29
How long should I make the description for this bug report that probably has a one line fix? I'm at three quarters of a page right now but I think I could keep going.
Sam
Sam
Hey all, I have a question regarding keeping database migrations (Alembic) in sync across my environment. I'm deploying services using container images (Flask servers) to a Kubernetes cluster. The cluster has a Postgres Helm chart inside of it to persist service data.
Inside my flask service, I'm controlling db upgrades using flask-migrate which basically just wraps around Alembic. My dev environment builds the services in local Docker images, and when I'm happy with the code, I push it out to the Kubernetes cluster. The problem I'm facing is, if I perform multiple Db changes in my dev environment, it becomes out of sync with the Alembic version stored in Kubernetes, and I'm unsure how to go about keeping the two in sync..
@Kevin It depends. Does your company award badges for long descriptions in bug reports? Does your company maintain a ranking list of longest bug reports to date?
Paragraph 4 is a great jumping off point for a digression about what a bug really "is"
@Sam be more disciplined. That is, you should take the time to ensure that your migrations can be built up and down to whatever production is
If no: Can you write a bug report that's so long, they'll henceforth start awarding badges?
17:33
if you can't alembic downgrade <"master"> and alembic upgrade head (or is it HEAD?) as many times as you want, you don't actually have db schema migrations
Niiice.
Sam
Sam
@WayneWerner Can it be the case that I can perform +10 migrations (for instance) in my local setup, meaning the head of my Production Db is behind 10 commits.. but then still be able to upgrade to the latest version on production?
If your deploy process is doing alembic upgrade head, then I don't see why not. That's what I do
Sam
Sam
Kubernetes is kicking off that it cannot find a specific alembic version. Maybe I've been careless and deleted the migrations folder at some point
17:50
I just finished using SQLite to modify a database for my awful little test game. I feel so powerful.
look through your revisions - they tell you which ones the came from and which one they're going to
pineapple, Theo
Ah, awful little test games, my favorite genre of personal project.
There's nothing like coming up with a small feature such as "what if I made the screen shake every time the player collects a coin?" and discovering that you'd have to rewrite the entire class hierarchy from scratch to do it
At first I thought it would be a masterpiece. Then I took a few (a lot) hours to write the functions to create new characters and decided it wouldn't be a masterpiece.
All those cur.execute()s and conn.commit()s got to me
Maybe you could create a base class and delegate all of the committing/executing to that. I don't really know since I don't know what your code looks like.
There may be some other way, like a decorator or something.
Sam
Sam
@WayneWerner Yup, you're right. I should have been more disciplined. I deleted the migrations folder at some point and one of my environments was hanging onto a stale version
17:57
Yeah I managed to narrow it down to about four functions that actually use SQLite for each major thing I need to do in the database, but now I realized I didn't test one case so I have to rewrite the function for modifying values in the database.
Get yourself an ORM that cuts down all that boilerplate
00:00 - 18:0018:00 - 00:00

« first day (3167 days earlier)      last day (2006 days later) »