« first day (4463 days earlier)      last day (709 days later) » 

04:09
this last one is... just a typo, honestly how the heck this escaped this long I don't know
 
4 hours later…
08:14
hey all, first question here for the year, my understanding of asyncio.TaskGroup is that, it lets me handle multiple exceptions instead of the first exception I would get and cancels the others, it does not let me handle the exception and let the other tasks run, is this understanding correct or not?
what if my use case is "handle the errors but do not cancel the tasks"
08:27
There's no way to do that with a TaskGroup. The primary goal of TaskGroup is that exceptions cannot escape the way you could just ignore the exception of a Task. That means it must abort on the first exception and since it cannot rely on you resuming afterwards it has to cancel the other tasks.
You could build such an abstraction yourself using raw Tasks, though I'm not sure how you would make that ergonomic. You'd be looking at a scoped iterable of asynchronous exceptions, so a nested async with-for-await.
" it cannot rely on you resuming afterwards ", does this mean, I have an option to resume a cancelled task (in general with asyncio not with TaskGroup)?
What I mean is that it cannot rely on you resuming the TaskGroup's wait-for-exceptions.
There's no way to resume a cancelled task from the outside.
got it, slightly related question, how come I get an exception group if it cancels the other tasks on the first exception?
as in, how does it collect other exceptions from other tasks into an ExceptionGroup?
They could be failing at the same time. Cancellation is not instantaneous.
Say you open a task group to contact several hosts via network – but your network is down. In that case, all tasks will fail at the same time, then the task group notices the first failure and tries to cancel all tasks, then the task group sees they are all failed.
that makes sense, so if I have created 10 tasks, all 10 failed due to the same reason, my ExceptionGroup will always have 10 tasks? is that guaranteed for the above scenario
so the main selling point is, I do not "lose" / ignore exceptions this way
08:43
Yes, that's practically the only thing exception groups are there for.
thanks a lot for the help and explanation
What exception should I throw if I find conflicting configuration in one of my custom dataclasses? For example foo: ReadOnly[int] = Field(writable=True)
Looks like a TypeError to me.
The entire dataclass, i.e. the type, is broken with that definition.
Works for me. I doubt this is an exception anyone would try to catch, so it probably doesn't matter too much anyway
 
4 hours later…
12:26
hello i was following here for classification custom data evening morning. keras.io/examples/vision/… I could not do the data upload and tpu part. I'm trying to test with gpu. (FIRST QUESTION)
tfds.load(dataset_name, data_dir="gs://example-bucket/datapath") how can i change this part for myself ?
12:46
Depends on what dataset you want to use, I expect
my own dataset
I took all the photos myself
I'm following here but I'm lost . github.com/AarohiSingla/…
I see. I will peruse the documentation for wisdom
thank you very much
13:15
If you're just trying to test with gpu for now, I don't think you need to call tfds.load. When you follow github.com/AarohiSingla/…, what part are you getting lost at? For example, have you gotten it to print a sensible value for "Total number of images in the dataset"?
They are working
also trains the model.
keras.io/examples/vision/… I couldn't do it for here, only the tfds part
I skip this part for now,
github.com/AarohiSingla/… I have a question about this place
I believe you don't need to use tfds at all, since you have your own dataset. tfds is for publicly available datasets.
@OceanWaves Ok. What's your question?
I couldn't add the reporting part
# from sklearn.metrics import classification_report
# predIdxs = pre_model.predict(x, verbose = 1)
# predictions= np.argmax(predIdxs, axis=1)
#
# print(classification_report(labels, predictions,target_names=test_data.class_names))should be similar to this part of code
There is no target name part in the code on github. For me, 'evening' should be 'morning'
13:32
Hmm. What happens if you do print(classification_report(labels, predictions,target_names=dataset_path))?
I am trying
this part is missing predictions
that's a surprising error message
I see the IDE was set to Tab Width: random
@AndrasDeak--СлаваУкраїні it's not my error it's my opinion
I did not add this definition predIdxs = model.predict(train_x, verbose
predictions= np.argmax(predIdxs, axis=1)
14:08
Traceback (most recent call last):
File "C:\Users\A\PycharmProjects\pythonProject8\test.py", line 142, in <module>
print(classification_report(labels,predictions,target_names=dataset_path))
File "C:\Users\A\Anacondainstallb\envs\tfow\lib\site-packages\sklearn\metrics\_classification.py", line 2310, in classification_report
y_type, y_true, y_pred = _check_targets(y_true, y_pred)
File "C:\Users\A\Anacondainstallb\envs\tfow\lib\site-packages\sklearn\metrics\_classification.py", line 86, in _check_targets
I get this error
Seems like labels has a length of 106, and predictions has a length of 100. That's no good. They need to be equal
(Or should that be "size" rather than "length"? Something like that)
images has the same length as labels, but then there's a train/test/ split and only a subset is fed to predict
@Kevin length because it's probably a multidimensional array (or equivalent), and len() traditionally gives you the size along the first dim.
14:25
@Kevin How can I fix ?
My first attempt would be feeding labels into train_test_split and only using the corresponding subset later. But this is just a guess, I don't do ML of any kind.
I like this idea
I don't understand how to change in code part.
Well, do you understand what your code does right now?
from sklearn.metrics import classification_report
predIdxs = model.predict(train_x, verbose = 1)
predictions= np.argmax(predIdxs, axis=1)
print(classification_report(labels,predictions,target_names=dataset_path)) When I remove this part, the errors disappear.
14:33
I'm glad it's solved then
the purpose was to make the report part
This is somewhat out of my depth
not resolved
@AndrasDeak--СлаваУкраїні a little abstract
(classification_report(labels, predictions,target_names=dataset_path))? I understood the target name part
14:36
I meant the rest of your code, how you set up the data and what train_test_split() does etc.
Because you should start by understanding that, and then it will be easier to figure out how to proceed.
@AndrasDeak--СлаваУкраїні ok i will do that.
300
300
15:30
Hi all. My first question here so hoping that I have followed room rules. I am trying to link to one of my questions which hasn't received any response 6 days. I haven't found a solution yet. stackoverflow.com/questions/74933710/…
@300 yup, all good, thanks. I don't know SQL but your question would probably have more views if it were tagged with the main tag. Version-specific tags should only be used for explicitly version-specific questions.
300
300
Oh, thank you Andras, I'll change that.
BTW I did narrow down problem to: How to convert list of tuples to csv file while keeping "" for empty string and nothing (not even empty quotes) for None (not string "None").
15:45
Does it make sense in a csv to distinguish an empty string from nothing?
For instance, if you read it back with the stdlib csv module, can you get something different for the two fields?
300
300
In my case, we are using that csv to load data into different DBs and that process loads "" as empty strings in DB while nothing is loaded as DB NULL. That is the reason I am trying to differentiate between two
Perhaps the process that loads data from the csv into the db, has a reverse mode that loads data from the db into a csv
For example, Oracle's impdp command has a corresponding expdp
300
300
Yes that's the current process, but it uses shell script and we are trying to convert it to use Python
Perhaps you could use subprocess, then
300
300
15:59
Except this one difference we are able to migrate the rest of functionality. And for this specific need are thinking to use subprocess and sed to remove "None" from the csv file after it's generated
@Kevin cue Fred taking off the mask from the monster captioned "Python", and it's bash underneath
300
300
@Kevin That is exactly what we are thinking to do now :)
If the existing shell script can already import the data without having to remove any "None"s and so forth, then you should be able to do the same thing in Python
I assume having unquoted fields and fields containing literal quotes would be a bad option
@Kevin I think the issue is "without row operations", i.e. while avoiding an explicit Python loop over db rows (if I understand the motivation correctly)
300
300
Yes, that is correct
16:02
(although I don't know if pd.to_csv() might use a loop under the hood anyway)
The design I have in mind would have zero loops. Take your existing shell script, which I imagine is something like expdmp myfile.csv --foo --bar --baz, and replace it with a python script like subprocess.run(["expdmp", "myfile.csv", "--foo", "--bar", "--baz"])
then "do the same thing in Python" was a bit misleading choice of words
I am a slippery lil weasel
not to be confused with a slippery eel easel
300
300
@AndrasDeak--СлаваУкраїні I agree, would be hard to explain why to convert to Python at all :(
16:07
well one reason would be maintainability in case the shell script is fragile and an unmaintainable mess (as shell script often are)
but any system will have a shell so it's not like it's a huge dependency to require a shell as part of the workflow
Ok, I'll table the "just put the whole thing inside subprocess.run" suggestion.
All other things being equal, I like my own scripts to have as little subprocess as possible
Does the utility you're using in the shell script have python bindings?
300
300
@0x263A Sorry, didn't get your question. But it doesn't have a way to interact with Python unless we use something like subprocess or sh
Hmm, is there a way to create a copy of a typing.Union? I assume Union[OriginalUnionToBeCopied] will work but that would look a bit quirky.
300
300
@AndrasDeak--СлаваУкраїні I am not aware about typing.Union Is it some utility that can be used from Python?
16:21
it's part of the standard library, it's a class that lets you claim that certain variables have types that are among a set of specific "types"
the keyword is "Python type hinting" or "Python typing"
300
300
Okay, I'll check it out. Thank you for suggesting this
you're not really missing out though
16:46
Do you mean a type alias? NewName = OriginalUnionToBeCopied?
That's my best interpretation of what it means to "copy" a type
no, because the original has a __doc__ slapped on for Sphinx, and I want the copy to have a different __doc__ (due to a deprecation)
Oh, a doc comment? Those #: thingies?
no, a literal string-valued __doc__ attribute
I thought doc comment were those triple quote thingies?
16:49
hmm
Yeah, how does a Union get a docstring? I'm confused
me too
only thing related I found was this: stackoverflow.com/questions/9195455/… but I don't think this is it
keras.io/examples/vision/… I will ask one last thing
I couldn't add the data augmentation part to my code
actually, I did find this, which is more closely related to Sphinx: sphinx-doc.org/en/master/usage/restructuredtext/… but I didn't yet find a runnable example to compare (I feel like triple quotes would have been there, but they aren't)
I'm specifically talking about github.com/pyvista/pyvista/blob/…. I don't know what configuration of docstring comments were tried before hacking on a __doc__, this was the first version on the PR that added it. It gets rendered as docs.pyvista.org/api/utilities/_autosummary/… which is as good as sphinx gets.
weird though that Union is picked up by intersphinx but Tuple isn't...
16:57
I see. Never saw Union being used like this before :o
Nice, OP's "solved" edit posted as CW, deleted by review stackoverflow.com/questions/40748886/…
Oh, those are some certified shenaningans
I don't think it gets any better than Union[OldUnion] tbh
I have half a mind to try with the triple-quoted string, but it takes about an hour to build the docs :|
yeah, using triple quote is a pain, even with autocomplete
@Aran-Fey OK, thanks. I've already confirmed that that works fine. It even strips the redundant Union.
@NordineLotfi that is completely not my issue, but thanks
17:04
You can try making an alias with a doc-comment, but I doubt it'll work
#: New doc
NewUnion = OldUnion
Is that supposed to be an alternative of a triple-quoted string after the name?
And that would only affect sphinx, right? The great part about hacking a dunder is that help(NewUnion) works... :P
Yeah. At least it was a couple of years ago, when I last did something with sphinx
OK, thanks, I might give that too a shot
@AndrasDeak--СлаваУкраїні ah, yeah looking at this github issue, I can imagine that the build time could vary based on how you structure the doc? Not sure since I never tried using Sphinx.
indeed, much documentation builds slow and little documentation can build fast, as it is
 
1 hour later…
18:34
can we see the deleted post content ?
10k rep users can see deleted posts
18:54
okay, thanks
19:28
This web framework lets me specify the href of a link, but not its onclick. I need to trigger some js when the link is clicked. The internet tells me that href="javascript:doThing()" is bad and I shouldn't do it. A dilemma.
Surely you can include a script though, right? Something like document.getElementById('your-link').onclick = doThing?
To be more precise, the web framework lets me specify the href of the link, and absolutely nothing else on the page. So I probably won't be doing href="javascript:doThing()", but rather href="javascript:{var a = foo(); var b = baz(); if (a !== b){doThing1();}else{doThing2();} doThing3(); $.ajax({etc etc etc});}"
Oof
Have you tried HTML injection? href='foo.bar"><script>...</script><dummy '?
It's not off the table
On the bright side, the framework is open source and changing it to suit my purposes is probably within my technical ability. On the dark side, getting my PR accepted may be beyond my bureaucratic ability.
How about a fork? Or is that off the table?
(Don't answer that, just pretend it was funny)
 
1 hour later…
20:58
Hello all, I'm looking for an example of a python class that wraps or ecapsulates anothe r python packages functionality. this is for my own practice purposes for learning python. let me know , if anyone can suggest any examples
Check out decorators.
I'm not sure why it's relevant that it wraps another package? What difference does it make whether the class uses your own functions or someone else's functions? At the end of the day, that's a class like any other
@Aran-Fey - that is true. but i'm new to python but i'm trying to create a python package which leverages few of existing python libraries and i wanted an example so that i can follow such that i meet certain code standards/conventions
21:14
Well, I don't know if this will help you, but I have a module where I extended some standard library classes. See here for example
21:56
Can someone that knows TensorFlow help assess this answer? Will tf.constant even accept [[1, 2, 3, 4], [5]] as an argument? Wouldn't that have to be a ragged tensor?
And the second code block passes several of these to tf.constant...
22:11
@GeneralGrievance I don't, but isn't that something that can easily be tested?
22:45
Could be, but I wasn't on a computer where I could test it. TIO doesn't come with TF.

« first day (4463 days earlier)      last day (709 days later) »