« first day (4115 days earlier)      last day (816 days later) » 

7:01 AM
cbg
 
I haven't done any PR before, so I was wondering do people normally do PR for PEP8 compliance? Any professional opinion?
 
Well - PEP8 is just a guide... if the author of a project is doing things "their way"... I'd probably not get too enthusiastic about re-formatting it...
 
I am the author and I did write the code my way with my readability in mind but I got PR and it is compliant with PEP8, IDK if I should merge it or not, because then I would be forced to write the future codes in following PEP8 too?
 
7:18 AM
cbg folks
 
cbg
@DelriusEuphoria isn't pep8 or flake8 standard ?
 
@DelriusEuphoria it's generally better to try and stick to some standard and PEP8 is a good one to follow but ultimately it's up to you... if everyone sticks to more or less the same formatting guidelines though - it tends to make life easier for all to contribute...
 
well, I will say that pep8 is nice overall. you can choose what rules you wish to follow, but staying largely consistent with pep8 will make your project more accessible to others. If that's something you're interested in, it might be well worth the investment. However, if all the PR does is a "drive by" pep8-ify your code, you can consider reviewing pep8 for yourself and choosing the parts that make sense.
 
what about Flake8?
 
either way, it might be worth your time investment. if you're worried it takes too long, there's also autoformatters like black that could take the workload off of you...for a price (autoformatting means you give up control, and you may not always like its results).
flake8 is a linter. it itself is primarily following rules/guidelines* set by pep8, among other things.
 
7:21 AM
oh i see
 
Re pep8, if you're not used to it, give it time. it will grow on you quick.
 
so pep8 is the rule book & pylint, flake8 etc are linters right?
 
@JonClements That's true
@ParitoshSingh Hmmm, maybe I'll give it a shot, it does no harm I suppose :P
 
@Aqua4 pretty much. pep8 does say it's only a "guide", and that you should use your judgement as you see fit.
question, does the following snippet work for folks here? also, what pandas version?
import numpy as np
import pandas as pd

np.random.seed(500)
test_df = pd.DataFrame({
    'a': np.random.randint(low=0, high=1000, size=10000),
    'b': np.random.choice([1, 2, 4, 7, np.nan], size=10000, p=([0.2475]*4 + [0.01]))
})
test_df.groupby('a').transform(pd.DataFrame.interpolate)
 
TypeError: Transform function invalid for data types
in pandas==1.3.5
 
7:40 AM
@ParitoshSingh seems to work (I say work - it gives output at least) with pandas=1.2.2 and numpy==1.20.1
 
thanks. okay that narrows the window down some.
For context, My actual code does a groupby apply -> interpolate and it's performance is kind of terrible. this answer suggested transform would get a performance improvement, but best i can tell, it's completely borked on new pandas versions.
 
Not exactly relevant to your problem, Paritosh, but consider upgrading to the new Numpy random stuff.
Dec 18 '21 at 18:25, by PM 2Ring
BTW, Numpy has upgraded to a better default randomizer than Mersenne Twister. The new one, PCG64 is faster, simpler, and has better randomness, although the difference in randomness is only significant if you need lots of random numbers, eg a big Monte Carlo sim. See https://numpy.org/doc/stable/reference/random/index.html?quick-start#quick-start & https://www.pcg-random.org/
Mersenne Twister (MT19937) was a big improvement over most PRNGs available at the time it was first released. And its huge period (2^19937-1) certainly sounds impressive. Over the years it's been learned that MT19937 has a few design flaws, but they aren't obvious due to the huge period. There are modern PRNGs that do a much better job than MT19937, with a much smaller RAM footprint.
 
8:01 AM
Ah, good to know.
uh, thats odd. i assumed rng.randint should have worked?
import numpy as np
import pandas as pd
from numpy.random import default_rng
rng = default_rng(seed=500)

test_df = pd.DataFrame({
    'a': rng.randint(low=0, high=1000, size=10000),
    'b': rng.choice([1, 2, 4, 7, np.nan], size=10000, p=([0.2475]*4 + [0.01]))
})
test_df.groupby('a').transform(pd.DataFrame.interpolate)
is this correct?
oh maybe it's the env im in right now. sec
 
Ugh... Meatloaf has died ;(
 
Oh. :( And we lost his collaborator, Jim Steinman, last April.
 
In death, a member of Project Mayhem has a name. His name is Robert Paulson - I think Fight Club needs a watch later...
 
8:17 AM
@ParitoshSingh Should be rng.integers.
 
thanks!
 
Just RTFM :P
int ranges being open and closed are always a gamble so better look it up anyway
 
It's hard to adjust to a new name when randint is burned into your brain circuits. Even if the new name is simpler. ;)
 
looks like now that it has an endpoint arg, i think it's much nicer. I can get used to this.
 
The old API had both randint and random_integers. Latter was right-inclusive.
@ParitoshSingh yeah, that
 
8:29 AM
The other day, I had to make some random integers in JavaScript. I was startled to learn that the stdlib still doesn't give you anything apart from a random float, 0<=x<1. There isn't even a seed function.
It'd be nice if PCG gets added to the Python random module. It shouldn't be that hard to do.
OTOH, I guess there isn't much incentive, since most big consumers of random numbers are presumably using Numpy.
 
9:11 AM
I've occasionally run into problems because MT was too small for random.shuffle and such. Having a larger or arbitrary size PRNG would be interesting, even if throughput isn't that relevant.
 
 
2 hours later…
10:45 AM
@MisterMiyagi I imagine that thinking "MT is too small for me" makes one question their career choices
 
do you prefer [*map(...)] or list(map(...))?
 
@solid.py list map
 
sure but why?
 
Former is "cute" but more obscure (harder for newbies to understand) and less readable. Semantics aren't as clear as the second case: convert this to a list.
if you're using square brackets you might as well use a list comprehension instead of map
 
You do have a point. I was also curious if both syntaxes produce the same amount of operations.
 
10:50 AM
They will do different things. You could shadow the name list and make the second one call that arbitrary function.
You can call dis.dis on both expressions to see what they compile to.
First one will have something like BUILD_LIST, second one CALL_FUNCTION, I think. And there's the unpacking in the first one.
To be clear you should abstract away the map for this: compare dis.dis('[*potato]') and dis.dis('list(potato)')
 
Thanks, this cleared things up a bit.
 
11:04 AM
no problem
 
@AndrasDeak It's somewhere at 2k elements, which isn't all that much.
 
huh
 
Yeah, exactly.
 
And how does the smallness manifest itself? Correlations?
 
It's knowing how to calculate it that makes me question my career choices. :P
 
11:06 AM
hehe
 
@AndrasDeak Some permutations can never happen. It's like shuffling [0, 1, 2, 3] and you only ever get [0, 3, 1, 2], [3, 1, 0, 2] and [0, 1, 3, 2].
That's not a big deal if you just need some random order, but if you keep further processing and selecting from the result you can run into trouble.
 
ooh, nasty
How painful was it to track that down the first time?
 
Only moderately, in that case it was clear that there was some size dependency and we got stuck at large sizes.
 
that's something at least
 
 
1 hour later…
12:34 PM
With every day that goes by I can relate to this guy more
 
hahaha
 
I am confused by lambda functions in Python. In this line make_vec_env(lambda: BitFlipEnv(array_length=50), n_envs=12) what exactly is being passed to the make_vec_env function?
 
@Aran-Fey that's absolutely fantastic, is this really real?
 
@Anush a function, i.e. lambda: BitFlipEnv(array_length=50)
it's a function with 0 parameters, when you call it it returns BitFlipEnv(array_length=50).
 
@AndrasDeak oh I see. So the n_envs=12 is just passed as a second argument?
 
12:43 PM
exactly
 
thank you. That confused me. I thought somehow n_envs=12 was being passed as an argument to BitFlipEnv(array_length=50)
 
you can try replacing make_vec_env with a function of your own that prints its arguments
 
so if you if you didn't have the lambda what would it have passed?
 
What do you mean?
 
as in make_vec_env(BitFlipEnv(array_length=50), n_envs=12)
 
12:44 PM
@ParitoshSingh Not sure. Here's the original tweet with a screenshot of a PR to back it up, but that could easily be fabricated
 
@Anush that would 1. call the inner function before it calls the outer function, and 2. not pass a callable as the first parameter of make_vec_env even though it probably should
 
@Anush It would have passed a BitFlipEnv object.
 
@Aran-Fey that screenshot says on Mar 32.
 
# equivalent proper function:
def delayed_evaluation():
    return BitFlipEnv(array_length=50)

make_vec_env(delayed_evaluation, n_envs=12)
 
thank you that is very helpful
 
12:46 PM
@ParitoshSingh Oh, so it does. Definitely real then :D
 
I think the key point is that it produces a new BitFlipEnv each time you call it
 
:D but still absolutely funny hehe
re lambda, just remember, a lambda is just a function, nothing really magical about it.
 
@Anush that would also be true the other way around. It probably has to do with whatever make_vec_env does. This looks like a callback.
 
Or I guess not a callback. A factory?
 
12:47 PM
stable_baselines.common.cmd_util.make_vec_env(env_id, n_envs=1, seed=None, start_index=0, monitor_dir=None, wrapper_class=None, env_kwargs=None, vec_env_cls=None, vec_env_kwargs=None)
 
> env_id – (str or Type[gym.Env]) the environment ID or the environment class
I don't get it then, it isn't supposed to accept a callable that returns an Env.
I'm thinking this needs domain knowledge I don't have.
 
:( me neither
 
Ah, OK, I guess with n_envs you indeed spawn multiple instances of the first arg, which is why you need a callable. If you didn't want to specify array_length=50 you could just pass BitFlipEnv. In other words, this might just be an alternative to functools.partial(BitFlipEnv, array_length=50).
In which case the documentation might be confusing.
 
The type annotation is just wrong, they really want a callable that returns an Env. The code does env = env_id(**env_kwargs)
 
1:04 PM
@Aran-Fey I don't feel I know enough to be able to raise an issue about that
 
Ah, I get it, the type hint doesn't say gym.Env (which would mean the parameter is an instance of Env(), it rather says Type[gym.Env] (<-> type(env_instance)) which means the parameter is an instance of the type, i.e. the class itself.
And the text says "enviroment class". So it's correct, just confusing (to us all).
 
thanks for working this out for us!
 
I can still be wrong because Aran is the one who actually knows typing, and I don't :P Provisory explanation.
 
:)
 
You're correct that Type[gym.Env] means "a class that's a subclass of gym.Env". But the code doesn't actually require a class, it just needs something callable that returns an instance of the class. Which is why you can pass in a lambda
 
1:12 PM
I guess it's duck typed
But I understand that typing to some kind of Callable would be better because that would include the class too.
especially since you can include return types too
 
 
1 hour later…
2:34 PM
I should learn typing because it seems like a rich source of strange and impractical puzzles
 
You mean hitting the keyboard keys right?
 
All of my problems do seem to start from me touching my keyboard
 
Only one solution... Don't touch it!
 
2:54 PM
pebkac that's my problem
 
indeed :P
 
3:48 PM
Sometimes I don't even need to touch my keyboard to create problems. I use Windows, you see, and its ways are mysterious to mere mortals.
 
I did not need to read after "I use windows.." :P
 
4:35 PM
hello, to change the prefix of a formset is it like this?: formset = ParteFormSet(request.POST, request.FILES, prefix='article')

is that I did it like this but nothing happens
 
 
2 hours later…
6:48 PM
Ran into a problem while tinkering with my WLAN... I thought I had a stroke of luck when I found a post with exactly the same problem as mine, and an accepted answer. But it turns out the answer was not particularly helpful, and the OP eventually fixed the problem by reinstalling Windows.
 
7:08 PM
then you thought you had a regular stroke
 
Even if I never fix this problem, my practical goal is 95% achieved. Laptop KEV10 can create/read/update/delete files within the shared folder hosted on laptop KEV7. KEV7 can't see folders hosted by KEV10, but it's not as if I need both.
The only thing I can't do is make changes from KEV10 while KEV7 is asleep or shut down. I suppose I prefer that to the other way around, because KEV7 only sleeps when I do, whereas KEV10 naps frequently
 
7:42 PM
Does anyone know if I can host a Django project on Hostmonster and put the database on AWS? What dou you recommend? It's the first time I've uploaded a django app to cyberspace and I'm in shock
 
8:07 PM
@AnaidBracho I suspect that the answer to that is "yes" with 99% confidence, but I can't be completely sure because I haven't done it
Are you using redshift?
 
@roganjosh OK thank you very much :) By the way I don't know what redshift is
 
In which case, what is a "database on AWS"?
They have like a bajillion different products that, to me, seemingly overlap on 90% of their functionality so I'm never properly clear on it :/
 
@roganjosh oh ok it's that whoever is running the project in django asked me to have the hosted site and the site's database in AWS in hostmonster. I have no idea if that can be done or if it would be better all in one place like AWS or digitalo ocean. It is my first app that I upload
@roganjosh It's just that it's too much information, I don't know anything either D:
 
I do know stuff in this space, but it's not always easy to connect the dots, so I empathise
It looks like hostmonster (that I haven't encountered until now) has the backing of postgres as a minimum. You will probably get a connection string to connect to the database storage that you supply
In terms of digitalocean, that's what I use to host my own website so I know a bit more about that, although I still just run sqlite3. I can't remember whether my subscription includes any managed storage (I think it probably does)
Yeah, it apparently does though the node option looks expensive when I could just spin up a postgres server on my own instance. It depends what you're actually developing. My own server is over-spec'd
A different way to look at it; you're just buying a linux box. That's it - just linux on someone else's (not Joe Bloggs, but some company's data centre) machine. I bought my domain name separately and hooked it up. The database you're reading about is probably managed storage, which means they'll take snapshots of it at some interval. Do you need that? If yes, they'll give you a connection string so you can connect to the little bit of database space they carved out for you
Otherwise, you could just run your own database server on the box that you just bought, and your whole box will probably get backed up at intervals. You just don't have anyone helping with the DB management. It probably depends on what you want to pay for vs. just doing it yourself
 
8:29 PM
@roganjosh Ok, so mmmm if I'm new to uploading sites what do you recommend? better in digital ocean I upload everything (site and database)?
 
It totally depends on your context. If you're just playing about then this probably isn't even necessary
What do you need at the end of all this?
 
I'm glad roganjosh is here because I know nothing about this space
 
@roganjosh Well, look, it's an app where clients who want to fix their houses register, budgets are made, mmm, they upload photographs
 
So it's a commercial product, not a toy/hobby/other?
 
@roganjosh it's a commercial product
 
8:40 PM
Do you have anyone internally that you think will be able to take this forward or are you leading the project?
 
@roganjosh mm it would be just me
 
How do the budgets get made? If it's a computationally intensive task that needs to run in its own process, that might affect what features you need to pay for
 
Ok, then managed storage is probably a decent way to go, and get something cost-effective. It'll fall down for anything but small companies, so you need to prepare for that. I would keep costs low and iterate
 
@Kevin You see budgets are 3 formsets where one adds values ​​and those same values ​​do operations (multiplications, percentages). 4 photos of the budget are uploaded. At the end the total is displayed. Clients, construction materials, workers who would work on the project, suppliers are registered. A graph to see how sales are going
@roganjosh what option would that be?
 
Ok, doesn't sound too intensive
 
8:48 PM
@Kevin Ah good!! I thought it would be great. Well, it is my first project, apart from that he wants to sell it so that people can use it for their budgets
 
@AnaidBracho you need something with managed storage, given that it's your first project. As to which specific option is best, I don't have a suggestion on that. But for sure, if you go with a vendor that gives you DB storage, you'll get a connection string.
Beyond that, I hope you're familiar with things like SQL Injection and the difficulties that come with web-dev. Given your questioning, I just want to make sure you know the potential scale of the difficulty with setting something like this up, given that you'll have client data
 
@roganjosh ok then i will look for something with managed storage for django, at least you already gave me a guide, you and kevin already told me where to look
 
django doesn't use managed storage
 
@roganjosh Let's see that about the client's data... do I have to be scared? Remember that it is my first project D: so other people are going to steal your data?
 
It's a web framework as link from your frontend web page to the backend data store. This is what's raising some alarm bells in my head
 
8:56 PM
@roganjosh ahhh ok then is it going to be a separate service? this gets complicated
 
You don't need to ping me on every message btw; I do follow the chat :)
 
@roganjosh ok sorry, ok I understand that not having django managed storage makes my app vulnerable to attacks?
 
Still the pinging. Anyway, no, that isn't at all what I'm saying. There is no managed storage for django. django is a framework that connects to a database (whatever that may be; postgres/MySQL/other) and the JavaScript interface that people use. The managed storage applies to the database - it couldn't give a hoot whether you have your app in Flask/django, for example
 
ok well, I will look for the option that you say adapted to my app, and if I have problems I will come to visit here again
 
Your app will be vulnerable to attack regardless of whether you have managed storage or not, and it will be attacked once you open ports. Managed storage just gives you a chance to rewind the damage, but that's hardly ideal
 
9:06 PM
ok does not sound so good for the app or for the clients
 
It isn't. This is why I'm trying to brace you for the first iteration to fail if you haven't worked in this space.
My own website is pure vanity - it has no commercial purpose, so, well, if it goes down, so be it. Still, the amount of spam I got messaged was in the 10s to 100s of messages a day before I put the recaptcha in
 
ok I will take it into account, thank you very much for notifying me of those details
gosh, well it will be my first experiment
 

« first day (4115 days earlier)      last day (816 days later) »