« first day (3833 days earlier)      last day (1098 days later) » 

3:29 AM
On a scale of "eh, that'll work" to "abomination", how bad would it be if I, say, used the current day of the month(integer) as a default argument to a function decorated by @lru_cache() in order to invalidate it every day, so that the current day's 'latest' data isn't cached until the application is restarted? Assume that the current day's data will be loaded by default/most often, and thus desirably remain in the cache at least for the day.
 
3:44 AM
Hi, i wanted to know if there are any packages that give graphs that are interactive like the plots output from matlab.... basically, I would like to see a value when I hover my mouse over a datapoint in the plot.. I am talking for the case of Jupyter Notebook
 
3:56 AM
@cmk101010 most plotting libraries have an interactive graph mode but I'm not sure how hard that is to access from a notebook
 
 
4 hours later…
7:59 AM
@Aran-Fey Wondering how dataclasses would decide which parameters to pass to the super __init__. Any ideas?
@toonarmycaptain That probably won't work as intended. Default arguments are not used for the cache key.
If you really want to invalidate the cache every day, just call clear() on it regularly.
Unless you have some very erratic accesses, an lru_cache with about 10%-50% more room than expected accesses per day should work automagically though.
For common accesses, even a cache smaller than the expected access count works fine. Helps to buffer repeated accesses, and won't hurt with infrequent actions.
 
@MisterMiyagi Well, the problem is really the order in which dataclasses accept their arguments. If you have a Bar dataclass inheriting from a Foo dataclass, the arguments are ordered like (foo, bar). Because of this design decision, the child class has to know what arguments its parent class(es) accept. (Which it doesn't, of course, but it pretends to know.) If the __init__ was implemented like (bar, *args) or (**kwargs, bar) instead, deciding which arguments to pass on would be easy
I guess they could implement it like (*args, bar, **kwargs)
 
Accepting <positionals>, *args, <kws>, **kwargs and then doing super().__init__(*args, **kwargs) should work, right?
 
Well, not exactly like that, because then bar would be keyword-only. What I mean is it should either look for a bar= kwarg, or use the last positional argument as the value for bar
 
urgh, that sounds messy. So bar might be in either *args or **kwargs?
 
Yes. That's only necessary if they want to keep the current design with the order being (foo, bar) though (which they have to, because backwards compat)
 
8:15 AM
I'd probably go for inspecting annotations (if the parent is a dataclass) or __init__ signature if not, but at least the latter seems still somewhat messy.
Oh, looks like dataclass does the first already.
 
Right. Which is a problem if the base class is a dataclass with custom __init__ with a signature that differs from the usual dataclass __init__
 
Looking at the code, the dataclass+__init__ seems to be the most problematic case. One would have to check whether the stored field fast-path is invalidated by __init__.
The proper way seems to be to mark whether __init__ is custom or automatic, and check that when subclassing.
Any volunteers? :P
 
8:39 AM
Not me, I've got my hands full just convincing this guy that a better implementation is possible and desirable
 
Don't look at me, I'm still targeting 3.6 ;)
 
cbg-ning
 
cbg
 
9:04 AM
Can someone give me a hint on regular/context-free/... grammars? What's the minimum functionality required to match Python-like indentation / off-side rule?
 
9:29 AM
So many things are wrong with this code :D It could make a fun game like the two images which are similar but one has differences, just that the diffs here will be glaring to the more readable version:
t0 = threading.Timer(1, lambda: self.foo.request_stop())
t0.start()
t1 = threading.Timer(4, lambda: self.foo.request_settings())
t1.start()
t10 = threading.Timer(5, lambda: self.foo.load_settings())
t10.start()
t_start_1 = threading.Timer(6, lambda: self.foo.request_start())
t_start_1.start()
It's like he forgot that he can call things just one after the other without a thread and there is no need to time the things then, because they will be only executed after each other :D
 
Woooow, that's a new kind of bad ._.
 
can all of those be changed to self.foo.request_start instead of the lambda and so on?
im confused why the lambda was there in the first place
 
In theory, a lambda like that can make sense because the current value of self.foo might be different from the value of self.foo when the timer triggers.
But then again, if the value of self.foo can change, then doing this with multiple timers and delays is extra bad...
 
10:00 AM
@ParitoshSingh yes, this can simply be changed to self.foo.method
@Aran-Fey well, new I don't know. More like common xD
 
 
1 hour later…
11:22 AM
hi
im new to this site and python
 
@Sonic welcome
 
thanks man
r u the admin?
i hv a python question
can u help?
 
@Sonic I'm a room owner. My powers are confined to this room. If you don't mind, please spell out full words like "are" and "you" :) And you can edit/delete messages for 2 minutes in chat, so you don't have to append question marks like that on a separate line.
 
okay dokey!
 
@Sonic please first read our rules and see how to ask. Otherwise, sure.
@Sonic and thank you.
 
11:26 AM
I need some help figuring out a workaround for my dataclass problem. I have a class decorator that creates/replaces the class's __init__ method. This works fine when combined with @dataclass as long as you take care to use the decorators in the correct order. The problem arises when a child-dataclass is created: Because dataclasses don't chain-call parent __init__s, my class doesn't work correctly. Here's a small demo of that
Now, I could write a @my_custom_dataclass decorator that takes special care to chain-call all the required __init__s afterwards, but that would only solve the problem for my specific decorator. What if someone needs to apply a 3rd class decorator to their class? They'd be screwed. So how can this be solved properly?
 
11:40 AM
If I try to change how dataclasses initialize their instances and make them chain-call all the parent __init__s, I want to avoid calling regular dataclass __init__s for no reason (e.g. after Child.__init__ has initialized all the dataclass attributes, calling Parent.__init__ would only re-initialize some of those attributes. I want to avoid this because of reasons).
And even if I can somehow identify whether an __init__ method was generated by @dataclass (and I skip calling it), there's still the problem that any well-written __init__ method will call super().__init__, and end up calling a dataclass __init__ anyway
 
11:54 AM
Back when dataclasses were still new, I wrote a clone of it so that I could use it pre-3.7. A while later I felt stupid for that. But now, now I feel validated.
 
12:10 PM
hello i want a litile help here .. i create signup and edit profile using django but i need help with my code stackoverflow.com/questions/67067501/…
 
i'll be able to take a look at this more thoroughly only in a bit Aran, but just to perhaps give some initial ideas, would __post_init__ help?
it's the dataclass version of "i need to do some work after the init is run"
not sure yet if it applies to your problem or not, since i am currently neck deep in some other work
 
Unfortunately __post_init__ doesn't help, because the __init__ method generated by my class decorator needs to run before the dataclass __init__ assigns instance attributes
 
should we consider messing with __new__ then perhaps?
 
Now that's an interesting idea
I'm sure I could think of one or two problems with that approach if I tried hard enough, but I don't wanna. It's dataclass's fault, so who cares
 
12:32 PM
@Aran-Fey if you basically just want to patch the generated method, consider to use __init_subclass__. That might be enough to wrap the __init__ with something that does the proper super delegation.
Truth be told, I've stopped using dataclass/NamedTuple for anything that needs even just the slightest extra features.
 
I thought of that, but __init_subclass__ is called before the @dataclass decorator, so there's no __init__ method to patch
But wow, correctly writing code that generates or replaces an existing dundermethod sure isn't easy
(mostly because of descriptors)
But it's dataclass's fault anyway, so who cares
I also realized today that I've been using @dataclass too much. The amount of boilerplate code for mutable default values is so high that you might as well just write the __init__ method yourself instead of letting @dataclass do it for you
 
@MisterMiyagi Didn't you all help me go down a rabbit hole a few weeks ago that involved __init_subclass__. I can tell you I do not recommend meddling with these things, there be dragons here. Then again, I'm sure you know way more about the inner working of python, so you might be able to use it properly
 
@Hakaishin I just point at the path. Whether to walk it is not for me to decide. fetches popcorn
@Aran-Fey That's probably the best approach, TBH.
 
1:04 PM
Timing-sensitive project update: ported to a threaded design, no observed drop in result quality.
My next desired feature will double the CPU usage, so I think I'll go right back to fretting
 
1:21 PM
I have a growing collection of functions that have no visible effect during their normal execution, because they only send signals to another thread to queue up a task that it will eventually perform. I'm trying to decide if I should make this evident in the function's name. A reader might expect reticulate_splines to block until all splines are reticulated, but they wouldn't expect that for asynchronously_reticulate_splines
 
schedule_spine_reticulation?
probably wouldn't hurt to try and convey the asyncness in the name
 
async def reticulate_splines? :P
I_cant_believe_it_doesnt_reticulate_splines
 
look at the wise guy
 
reticulate_splines_eventually
 
ugh, I wrote "spines"
 
1:24 PM
reticulate_splines_quite_quickly_because_the_queue_is_usually_idle_but_nevertheless_odds_are_good_it_won't_finish_before_this_call_returns
I am once again asking the core devs to allow apostrophes in variable names
 
Cheap solution: add a block=False default argument that raises when you pass block=True
 
non-wise-suggestion: make it return a Future
 
It would be nice to have more control over the reticulator than just "here, do this eventually", so I am seriously considering doing something proper with async and tasks etc
 
do I need to make any more wise guy comments, or is it obviously a bad idea?
 
Hi folks,
I am new to Python.
As far as I know, python is a interpreted programming language. How can python projects be published as executable binary applications?
 
1:29 PM
What, incorporating async? I don't think it's a bad idea if I have a very clear idea of what kind of control I want to have over my reticulator. Pause / unpause / halt-and-cleanup would be a good start.
Hard mode feature: rewind. Probably can't do this with just native async functions.
 
@Kevin If you can do it sync+threads, do it sync+threads.
@MoneySetsYouFree Python applications are usually shipped as source code. The Python interpreter is commonly available, or at least reasonably easy to install.
Do you actually need binaries?
 
I have incorporated your advice into my serious consideration algorithm, with high weight.
 
@MoneySetsYouFree A) don't do it. B) If you really have to check out pyinstaller, it's quite neat
 
@Kevin Now I feel bad for keeping you from months of fun... D:
 
Don't worry, there is an infinite fractal of complexity waiting for me, I just have to decide I want things to be 1% faster
while True: grep source code for "todo" or "eh good enough"; refactor()
 
1:33 PM
@MisterMiyagi Are executable python based applications in binary? In my understanding, executable files or libraries are always in binary form rather than text form. :-)
@Hakaishin OK. Thank you.
 
Any properly-formed file with the ".exe" extension is in binary
 
@MoneySetsYouFree Any file can be executable.
 
what the *, how is defining some class attributes able to swallow my exception?
class Something:
	def __init__(self):
		self.foo = Foo()
		self.bar = Bar()
		log.info("here")
		raise ExceptionSomet
 
(Insofar as "in binary" is a meaningful concept)
 
Philosophical answer: Text is just special binary.
 
1:34 PM
If I run this with foo and bar in place I see the log here, but never the exception. If I comment foo and bar the exception comes trough. What magic is this?
 
I was about to say, ascii txt files are simply binary files that choose not to use the funny looking characters.
 
@Hakaishin recursion error much?
 
?
Ah whoops
 
Interesting that you could see "here" in your log though. I can't replicate that, myself
 
OK guys, how can an interpreted language (such as Python) be compiled to an executable apps? It seems to be inconsistent with these categories "compiled" or "interpreted".
 
1:37 PM
Usually, it's just run. oO
There is no need for (separate) compilation.
The OS knows that it needs the Python interpreter to run your program.
On Unix, that happens via a shebang. On Windows it happens via file extensions.
 
You can't compile python into a standalone app. What you can do is bundle the script and the interpreter in an exe, so the exe contains everything that's necessary to run the script
 
@MoneySetsYouFree If you're asking how pyinstaller does it... If I understand correctlly, it "compiles" a script by taking the script, and all the scripts/modules/libraries the script uses, and the python interpreter's executable, and compresses/bundles them together inside the data portion of the exe. Then when the user opens the exe, it unbundles/uncompresses everything, runs the script with the interpreter, and packs it all back up when the program is done.
At no point does it take Python source code and/or byte code, and compile it into native assembly. So from that perspective, not even pyinstaller is "really" compiling it.
 
@MoneySetsYouFree for the record whenever you run a python script it also gets compiled
 
@Kevin I take it executable archives are not a Windows thing?
 
@MisterMiyagi Good question, I don't know. I freely admit that I'm fuzzing the details here.
 
1:41 PM
@Kevin Thank you very much! I understood. :-)
 
Speaking of which, has anyone tried nuitka? I keep on wanting to, but never manage...
 
Wikipedia tells me that executable archives for Windows can be created with a variety of programs: "WinZip, WinRAR, 7-Zip, WinUHA, KGB Archiver, Make SFX, the built-in IExpress wizard and many others, some experimental."
 
@MisterMiyagi interesting project
So weird, when I define a ZeroMQ publisher it swallows exceptions which come up later, something is very fishy
 
@Kevin That satisfies my understanding of Windows as "A Wizard Did It".
 
I just tried out the 7zip self-extractor.-maker It creates a .exe file. When you open it, a 7zip-branded window asks where you want to extract the files.
When I first heard "executable archive", I was imagining an executable that would extract its contents and then execute something. One of the exes it contained, or a shell command, whatever. I don't think 7zip lets you do that.
Perhaps because it could easily be used for evil? But when has that ever stopped anyone from publishing a cool thing...
<gestures broadly to the hundreds of silicon valley facial recognition startups that are lowkey gunning for military and police contracts>
 
1:56 PM
@Kevin me?, nono never... :P
 
Anyway it's not as if my imagined "executable executable archive" actually gives a sufficiently determined bad guy more power over your system. If you're running a skeezy executable, you're already dead.
Really it would just be of benefit to script kiddies who are only limited in their evil because of their level of talent
 
"Just embed it in a Word macro"
 
@Hakaishin It's OK, it's still ethical as long as you put in a couple self-destruct backdoors
Yell "swordfish" to make the murderbot stop what it's doing and begin the Fortnite Dance
I guess I shouldn't be preaching about ethics, being a part of the reticulated widget logistics industry. A clever mind can do things with a widget... Nefarious things
In a pinch they make a decent bludgeon
 
Another irrelevant question:

When using VS Code, we can configure a task on which the building process is based. In addition, we can also use CMake in VS Code to manage building process.

In my understanding, both tools are mutually exclusive. Is there any case in which we use both CMake and Task in Visual Studio Code? :-)
 
Perhaps you have a third party library that has provided a CMake-compliant makefile, but not a Task-compliant one. Perhaps you have another third party library that has the opposite. Including both libraries in your project might require you to use both tools.
I suspect this is not a very common occurrence
 
2:06 PM
@Kevin: Thank you very much. :-)
 
spammy trash is spammy i.stack.imgur.com/XJ7fj.png
 
2:24 PM
@AndrasDeak I mean... they're nice enough to leave half your browser window to read the content you came for.
 
2:49 PM
I'm trying to download these two datasets: podoce.dinf.usherbrooke.ca/challenge/dataset but the download crawls at 10KB/s and then after a while fails. I tried multiple times with pauses inbetween tries but no success. As it looks this is the largest dataset for the task, would you email the authors personal email or how would you ask for the data?
 
Hey guys
Anyone good with histograms?
x = col1 = [2011.005, 2012.6543, 2013.3456, 2014.7821, 2015.3421, 2016.7891, 2017.0173, 2018.1974]
y1 = col2 = [1.4356, "", 5.32245, 6.542, 7.567, .77558, "", ""]
y2 = col3 = [1.3345, 2.345, "", 5.356, 3.124, 6.12, "", ""]
y3 = col4 = [0.67, 4.235, "", 6.78, "", "", 9.56, ""]
I know how to plot this on scatter but how would I go about as a histogram?
 
@AmnesiaSmith probably using a histogram function in numpy or matplotlib. What are you really looking for?
 
the codes pls xD
 
This is dummy data that I created for creating a histogram/bar graph
I had to import a CSV file which had missing values
 
@AmnesiaSmith that's what I'm asking. A histogram is a histogram, a bar graph is a bar graph.
you represent histograms with bar graphs but the two are different things
 
3:03 PM
right so for this where its (x,y1) (x,y2), (x,y3) would it be better to plot a bar graph?
 
Maybe somebody could have a look at my weird issue, just creating this publisher doesn't swallow my exception, but starting it does. I'm trying to create an mvce but I can't really reproduce it. So I tried looking at the code it's not too much and I don't see anything obvious wrong
publisher = pubsub.ZmqPub(bind_address=(url.foo['address'], url.foo['port']), topic=url.foo['topic'])
publisher.start()
This is how I create it and here is the ZmqPub class gist.github.com/Kaju-Bubanja/fc66e2c5b1322e6b0cb1f5dd951a64bc
 
Oh yea sorry, I used both.
numpy for doing mean, sd etc and matplotlib for plotting
 
@Hakaishin I don't have the setup to test this right now, but are you sure it's not just the Thread swallowing the traceback?
 
to add more context I have:
class Foo:
    def __init__(self):
	publisher = pubsub.ZmqPub(bind_address=(url.foo['address'], url.foo['port']), topic=url.foo['topic'])
    	publisher.start()
    	raise Exception
I don't see why having a var which is a thread would swallow exceptions outside the thread?
 
No reason, just misunderstood the setup.
 
3:24 PM
Ha progress, I was like man my mvce doesn't reproduce, but I didn't check the original code. It also doesn't reproduce on my dev machine. So it must be that some things have different versions on the test machine
 
3:36 PM
cabbage
 
@AmnesiaSmith depends. Do you want to end up with a bar graph of that data?
 
3:52 PM
Hi all. I'm working with the cv2 and mss libs. I have two points (x and y tuples) for the top left and bottom right of a rectangle. How can I use these two values to re-screenshot that original points? My maths is bad here: location_to_screenshot_repeatedly = {"top": x, "left": y, "width": 200, "height": 200} but clearly x and y are not the right values here, along with cv2.imshow("Image", np.array(mss().grab(location_to_screenshot_repeatedly))). This is what I have.
(and what I get out is a different screenshot shown, so I'm messing up somewhere)
 
@Jimbo I've never seen mss and I've barely seen opencv, but the most straightforward source of bugs is probably a difference in coordinate systems. One with y going up and the other with y going down on the screen, for instance. Have you double-checked these?
 
probably {"top": x[1], "left": x[0], "width": y[0]-x[0], "height": y[1]-x[1]}?
 
oooh, good catch
 
Good suggestions, thanks I'll take a look at the coords systems and try the above (Y)
 
Hello.
Just earned the privelige of using this
 
3:59 PM
with a name like that you dont need a privilege :D
 
When will python 4.0 be out?
Python Programmer is the username
Just simple and to the point
Thanks @python_user
Does anyone here use the ursina engine? I am struggling to connect PyGame Joysticks to control Ursina engine entities. I use VS Code if that helps
 
in case you are not aware the next python version is 3.10 not 4, but from what I read if at all there is Py4 it wont be like Py2 to Py3 level change
 
Ok
Thanks
 
is there a timeout for when you can type messages into these rooms
 
4:02 PM
ohh it was from GvR that I read that laurel
 
Does anyone use Ursina Game Engine
Its a wrapper for Panda3D
Is anyone there?
 
... You know at least two of us are here, python_user and I just spoke.
 
other than the two people who just replied to you
 
After Python, also, what languages should I learn. I am quite advanced in Python now, writing Neural Networks at the moment.
 
ok, I am not a Room Owner(RO) but can you try to ask one focused question at a time?
 
4:04 PM
Sidebar says we have five non-idle users right now
 
Room Owner. Identified by an italic user name, like mine
 
Ok
@python_user I'll try
thank you. I am new to this
Going to go now.
 
I think you should learn Java, Lisp, C, x86 assembly, and Fortran. Nice well rounded skill set.
 
<--- idle-ish
 
4:09 PM
the RO italic user name is really not that eye catching unlike the mod style
 
For the same reason that janitor's uniforms aren't very fancy in real life ;-)
 
@Kevin OK
 
Java for boring OOP, Lisp for mind-bending functional programming, C for pain fun with pointer arithmetic, x86 for an authentic return-to-roots experience, Fortran for job security because they can't replace you when nobody else knows Fortran
 
OK. Never even Heard of Fortran before this
 
Exactly :-D
 
4:13 PM
@Kevin I hear the sciency folks are big on Fortran. Might want to use COBOL instead.
 
Hmm, true. And the list could use at least one language that's all-caps. (C doesn't count, it's clearly TitleCased, not CAPSCASED)
 
:D
When you google 'What programming language should I use for AI and Machine Learning' it comes up as saying python. If it is so good for it, why are there so few tutorials out there?
 
pardon?
 
not sure what you mean, I can see a dozen medium articles for any ML AI in python
 
4:16 PM
I googled it and it says Python straight away!
 
Keep in mind that a language that's good for doing AI is not necessarily good for learning to do AI
 
Perhaps the best AI language is so confusing to new users that only super geniuses ever manage to use it. Their programs are brilliant, of course, because they're super geniuses.
 
Isn't AI in practice basically just C++ with a nice Python frontend?
I hear the LISP folks lost the AI war...
 
people tell me my intelligence is artificial all the time.
 
4:22 PM
Gonna design me a language that is literally unusable unless you have 130+ IQ. Tech media will notice that my userbase consistently produces excellent work, and hail me as a visionary
 
what IQ is required to write such a language?
 
I'll call it "Malbolge minus minus"
@piRSquared For my sake I hope it's considerably less than 130
 
Getting poked, wish me luck
 
@cs95 Whoah! 1/2 way to being a superhero. GL!
 
4:57 PM
Thanks! Waiting for my superpowers now
 
Hey, all, I found a question that, on the face of it, is silly -- but it's an honest question and I have written an answer for it. Unfortunately, the OP was treated poorly and has deleted the question. I have cast one undelete vote -- anybody here willing to help reopen it so I can post an answer?
 
@EthanFurman have at it.
 
5:15 PM
Many thanks. :-)
 
5:44 PM
Closed
 
 
1 hour later…
6:46 PM
Hello everyone, I hope everything is alright with you all. I have been working on an equation that involves using integration. My question is, is it possible to use quad from scipy to integrate lists?
 
7:01 PM
@WDpad159 What do you mean by "integrate lists"? Can you show a code example to illustrate what you are trying to do?
 
@WDpad159 quad integrates multivariate scalar functions. If you have a vector-valued function there's things like quad_vec.
 
I have the code and question in this discussion: chat.stackoverflow.com/rooms/230933/…
 
 
2 hours later…
8:58 PM
How bad form is it to dupe stackoverflow.com/questions/49258553/… into stackoverflow.com/questions/47168152/… according to chronological order, when I answered the latter?
 
cbg, I was looking through the logging lib and I didn't see any way to open previous log files/do checks on them. Is there a nice way to do that without need to directly make the string operations? Was asked to check the the logs of another script to create some termination conditions for a script I had.
 
The newer questions asks why it's non-deterministic, but the older question itself explains that
 
hmm, why not just provide an answer citing the previous question?
are they asking for exact same output
 
good job reinventing duplicate closure :P
very closely related
 
it sounds like one wants to understand why and the other is more focused on how to circument the behavior
 
9:05 PM
The newer question is surprised at something that's the premise of the older question, and offers no solution.
 
SO isnt only about getting a snippet to copy and paste into code
 
No way!
 
so I can see different answers between the two, the newer one kind of being more like digging into the library or into file info
at bare minimum the accepted answer for the original question doesnt really satisfy the new question
this type of stuff is generally worse with JS questions though, where how you write JS changes every 18 months, so old questions that were kind of duplicates of each other stop being dupes or the dependency order for what could be merged should be flipped
tbh the SO duplicate stuff is pretty bad overall for handling JS questions cuz of that. 90% of the answers are done "the wrong way" now and dupes means those will probably not get re-asked (get too much attention)
 
@Skyler ideally newer answers should be posted on the dupe target
but yeah, obsoletion is a large unsolved problem on SO
 
@AndrasDeak
yea so now my code looks like:
how would I plot this as a bar graph?
 
9:17 PM
is there a reader module for python's standard logging library or a preferred way of doing it that isnt just some regex?
 
@Skyler: That kind of problem is why structlog exists.
Log parsing sucks. structlog's approach helps remove the need for parsing.
 
@AmnesiaSmith that has broken formatting and it's almost a bit too much code for chat. Please read out formatting guide and practice in the sandbox if necessary. Alternatively, post the code in a code paste site and link here.
 
That said, I don't know of any dedicated Python log parser tools.
 
is there a method to change a scatter plot to bar graphs maybe?
 
9:21 PM
@user2357112supportsMonica ok, and it looks like it can be built to work with logger, that seems like it could be relatively painless if I'm the first person doing real log parsing for the project
 
@AmnesiaSmith yes, by changing plt.scatter to plt.bar, usually
Have you looked at the documentation yet?
 
the sopython one?
 
@user2357112supportsMonica it works fine between two scripts right? looking at it and I'm trying to figure out if it annotates logs to be easy to pull as objects or if its just some kind of parallel state that exists during a projects running
 
Thank you! I'll look into that but yea my plot may not just need that, thank you!
 
I've been getting a surprising surge of downvotes on old posts for about a month now. That's way longer than any previous incident. I wonder if this is just one really dedicated revenge-downvoter, or multiple incidents that happened to occur close to each other.
 
9:27 PM
@AmnesiaSmith here's a little piece of advice that started making my life much easier(still working on this skill so itll take time): Search for whatever the main function you are working with is until you find the documentation for the library, and start off looking at the function to understand inputs and outputs, and then if you want any other explanatory docs they have, and if you still need more go back to the function and see if there's an option to link to the source code
usually similar functions are recommended or are in a sidebar if it's a "readthedoc" like website so you can often find answers and related things with a first look there
 
@Skyler: structlog is based around log records as dicts instead of strings. What you do with the dicts is up to you. You can format them into strings and forward them to logging, or save them as JSON, or save the data in a database, or do multiple of these things, or something else.
 
If I remember correctly, the idea was "We've moved away from logs being for humans to read, so let's make it easier for computers to read them."
 
ok, I'm dealing with a codebase that frankly is overannotated with logging so hopefully structlog can kind of just be plugged in the beginning and keep it simple
@piRSquared yea, logs need to just be barely readable for some monitoring here and there
frankly I wish the team I'm working with asserted more things and stopped the script instead of just silent trying, failing, and logging failures that will make the rest of the run useless, but alas I can only change what they let me
 
If you're dealing with a codebase that already has a ton of logging, you're not going to be able to quickly plug in structlog and change all that. Using structlog requires changes to how you do your logging.
For parsing your existing logs, it's probably time for some nasty regexes.
 
@AmnesiaSmith no, the documentation for pyplot.bar...
 
9:36 PM
luckily that's the thing, old logs dont really need parsing fortunately
I'm just examining the pipeline leading up to my script
 
@Skyler I thought you were specifically asking about parsing old logs.
 
@AndrasDeak they are other files, but run earlier in the pipeline
so they are maybe a few hours old
 
9:55 PM
Cbg y'all, I'm just a but confused about installing libraries without pip using setup.py. Will the installation be corrupted, if I remove the cloned githup repo?
 
probably depends on what you put after setup.py
But I would note that this is also easy enough to test for yourself.
 
@AndrasDeak I just use: python setup.py install
@AndrasDeak I just did not want to mess anything up.
 
@CoolCloud and that's why you didn't test this for yourself?
In a new, fresh virtualenv?
 
No I dont use virutalenv as of now. All on global python
 
Are you looking for a good reason to start using one? :P
 
10:09 PM
Got one
 
10:21 PM
I have a dataframe with one column having float values..
I am using a loop to go through every row of this dataframe by comparing to the timestamp column and then take out this float value and add it to a list of list, and finally convert this list of list to a data frame... but all my float values are getting converted to NaNs.
I tried applying np.arrray(df.column[i]).. but that didnt help either.
how to get around this?
 
You'll have to show an MCVE, we can't debug code we can't see.
 
for day in range(len(kt_daily['Day_type'])):
    date_1 = kt_daily.Datetime[day].date()
    for hour in range(len(kt_hourly['kt_mean'])):
        date_2 = kt_hourly.Datetime[hour].date()
        if date_1 == date_2 and kt_daily.Day_type[day] == 'Overcast':
            list_1.append([kt_hourly.Datetime[hour], 'Overcast', kt_hourly.kt_mean[hour]])
kt_hourly.kt_mean[hour] this is getting converted to NaN
 
does it also happen for kt_hourly.kt_mean.iloc[hour]?
 
no that didnt work either :(
 
OK, that's the extent of my pandas knowledge for want of an MCVE
but all those loops over dataframe columns smell very antipatterny
 
10:29 PM
it doesnt make sense that the Datetime column gets copied without issues but the kt_mean doesnt
i tired kt_hourly.kt_mean[hour].to_numpy()
but that gave me an error
 
an errors are the worst
 
hmm.. nothing is working... is there an error in my loop?
 
yes
 
btw, my list shows this
[Timestamp('2001-01-03 00:00:00+0100', tz='Europe/Paris', freq='H'),
'Overcast',
array(nan)]
oh what do u think is wrong in my loop?
 
No idea, but if the code doesn't do what you expect that's an error, at best a semantic one.
 
10:44 PM
Do u think i need a continue statement inside each if elif loop?
 
I don't see any elifs
 
oh sorry.. that was the first if... then there are a bunch of elif statements
for day in range(len(kt_daily['Day_type'])):
    date_1 = kt_daily.Datetime[day].date()
    for hour in range(len(kt_hourly['kt_mean'])):
        date_2 = kt_hourly.Datetime[hour].date()
        if date_1 == date_2 and kt_daily.Day_type[day] == 'Overcast':
            list_1.append([kt_hourly.Datetime[hour], 'Overcast', kt_hourly.kt_mean.iloc[hour]])
            continue
        elif date_1 == date_2 and kt_daily.Day_type[day] == 'Severely Overcast':
 
excellent
 
Any obvious errors u notice here?.. basically kt_daily has a length of 365 and
kt_hourly is 24*365 length... Both have a datetime column that I reference and kt_daily has a classifier column (kt_daily.Day_type)
 

« first day (3833 days earlier)      last day (1098 days later) »