« first day (3783 days earlier)      last day (1152 days later) » 

12:23 AM
Hi, I've got a pandas error which I can't replicate for a stackoverflow question :-/
given a dataframe like this:

df = pd.DataFrame({
'Fruits': ['apple', 'orange', 'banana', 'pineapple', 'watermelon'],
'Volume 1': [10, 20, 30, 700, 800],
'Volume 2': [100, 200, 300, 7000, 8000],
'Volume 3': [1, 2, 3, 70, 8],
'Volume 4': [9, 8, 7, 6, 5],
'Other': [-1, -2, -3, -4, -5]
})

this operation to move the values from 'Volume 2 to Volume 4', _does not throw an error_:

df.loc[:, 'Volume 2':'Volume 4'] = df.loc[:, 'Volume 2':'Volume 4'].shift(1)
the structure of the statement(s) is the same - 'shifting down by one' a few consecutive columns in the middle of the dataframe.

i've tried enlarging the df above to 100_000 rows but it still doesn't give the same warning.

should i just disable or ignore the warning in this case? (and what's causing it?) I've read the `SettingWithCopy` thread (https://stackoverflow.com/questions/20625582/how-to-deal-with-settingwithcopywarning-in-pandas)
 
Would divmod(a, b)[::-1] be better than a % b, a // b?
 
you want to reverse the quotient and remainder return value?
a) why not just flip the variables?
b) divmod is faster than the regular `a // b, a % b` but if you're reversing it also, then i'd recommend timing each operation
 
@aneroid Because flipping the variables won't return the correct result.
divmod(a, b)[::-1] returns a different tuple from divmod(b, a).
@aneroid Even without the flipping, divmod is slower because I'm working with smaller numbers; divmod is only faster if the numbers are large.
Thanks anyway!
 
I meant that you'd do `qout, remainder = divmod(a, b)`

Yeah, i just cheked, divmod is slower for small numbers
much slower (10x)
so yeah, better to just do a % b, a // b
 
@aneroid I'm storing the values into a list.
 
12:38 AM
@AnnZen for a small numbers, %timeit divmod(a, b)[::-1] is 194ns on my old machine. while a % b, a // b is just 10ns. so 20x faster
 
Yeah, I timed them too... with perf_counter().
 
@AnnZen nice find
 
Actually,
22 hours ago, by python_user
@AnnZen https://stackoverflow.com/questions/30079879/is-divmod-faster-than-using-the-and-operators maybe of some use
:)
 
@AnnZen if divmod was faster numbers you were using, you could do: q, r = divmod(a, b) and then mylist.append((r, q)) or mylist.extend([r, q]) (if it's not a list comprehension)
@AnnZen ah. even so.
 
Oh, it's a list comprehension.
ca:
 
12:45 AM
haha, then yeah. [::-1] would be faster.
 
self.food_indices = [divmod(i, self.cols)[::-1] for i, color in enumerate(self.data) if color == (255, 255, 0, 255)]
 
is the self.cols a typo in your code? since your're enumerating with color
 
@aneroid no, self.cols is the width of the image.
The colors are pixels of the image.
Oh, and the image is self.data.
 
@AnnZen so you're only want the food_indices to be for some images, which have that color ? (bright yellow?)
 
1:31 AM
cbg
 
@aneroid even more weird. I re-created the original dataframe, exec'ed all the code before it again. and then ran the .loc.shift lines again - and this time, no error
cbg
ps. for anyone who's not seen flying circus, it's on netflix now (for a few months actually)
 
@aneroid No, I want the coordinates of all the pixels of the image that are bright yellow.
 
user5556825
1:45 AM
are there multiple shades of bright yellow?
 
user5556825
nm, it's probably web safe color scheme
 
user5556825
here is what I was sort of thinking: #FFEE00 is websafe, and yet it could be mistaken for a full-on yellow, i.e. 255, 238, 0, 255
 
2:07 AM
well, any rgb with a repeated hex letter is websafe. effectively, `#fe0 == #ffee00` the fact that it's visually close is a different matter. even #ee0 is pretty close.
In order to get _approximately bright yellow_ you'd need to do some color-math...and not just using XYZ-axis based Euclidean distance calculations. it would have to be something using the "rgb space"
 
2:22 AM
I got my rep back after I delete a downvoted answer, i got some backlash last night and ended with -3
thought rep lost was lost
 
2:37 AM
@nickindiessance a) #ffee00 is not websafe (rapidtables.com/web/color/Web_Safe.html)
@aneroid b) "any rgb with a repeated hex letter is websafe" - untrue. repeated hex and only every 3rd hex (or something). so #000, #003, #006, etc. (hex codes with only 0, 3, 6, 9, C, F) and in pairs for 6-hex or any of those for 3-hex
 
 
1 hour later…
4:07 AM
@aneroid Wild guess, the other dataframe is a view of another dataframe. If you derive this dataframe from another, put .copy() to the end of the code where you define this dataframe and see what happens.
 
4:19 AM
@anky Actually, it's not. And the error randomly keeps popping up if I redo my 'shift' steps and column adding/removal. and I'm always re-referencing df so if it's not a view of another df, or the "other" gets de-referenced because of re-assignment to df. Looking for a way to replicate the error consistently but no luck so far.
 
hmm, okay. yes an example would help. especially the part where you say "I redo my 'shift' steps and column adding/removal"
 
So the shift steps are the one's from here - https://chat.stackoverflow.com/transcript/message/51650323#51650323. the adding an removing of columns - I was wrong, that happens in a `new_df` which gives no issues. the issues are only ever with `df`. and from read_csv to the shifts, until new_df is created, I'm only ever doing `df = df...something` so `df` is always itself.
i know it sounds really vague, so i didn't create a question for it. in my attempt to write a variant of the code which gives the error (fruits, above), the error doesn't occur. and then re-running my old code from read_cs
ok, found a way to replicate it...hold
up until shift(1) as per my code above... https://chat.stackoverflow.com/transcript/message/51650323#51650323
then:
df = df.dropna()
df.loc[:, 'Volume 2':'Volume 4'] = df.loc[:, 'Volume 2':'Volume 4'].astype(int)
so the full code:
df = pd.DataFrame({
'Fruits': ['apple', 'orange', 'banana', 'pineapple', 'watermelon'],
'Volume 1': [10, 20, 30, 700, 800],
'Volume 2': [100, 200, 300, 7000, 8000],
'Volume 3': [1, 2, 3, 70, 8],
'Volume 4': [9, 8, 7, 6, 5],
'Other': [-1, -2, -3, -4, -5]
})
df.loc[:, 'Volume 2':'Volume 4'] = df.loc[:, 'Volume 2':'Volume 4'].shift(1)
df = df.dropna()
df.loc[:, 'Volume 2':'Volume 4'] = df.loc[:, 'Volume 2':'Volume 4'].astype(int) # SettingWithCopyWarning warning

# and if i exec this line again:
 
4:53 AM
astype() is clearly creating a copy but since I'm assigning it back to df, doesn't that make it the original?
 
5:52 AM
that gave me the warning when i ran it, and then i opened documentation, read a few pages, changed nothing in the code and it..stopped. That warning is on to me.
 
@ParitoshSingh hahah, yeah ;-)
 
fwiw I did not get any warning
copy pasted every line after "so the full code"
 
6:11 AM
which version of pandas are you on?
0
Q: Assigning to column slices with df.loc and astype() *sometimes* issues SettingWithCopyWarning

aneroidThe code issuing the SettingWithCopyWarning can be fully replicated, and is not a duplicate of these 3 questions: python astype(str) gives SettingWithCopyWarning and requests I use loc "At some point prior to the assignment, you created df in such a way that it became a view into another datafr...

 
I tested on 3 different pandas version I have (1.2.2, 1.1.3, 1.0.1)
 
6:29 AM
@python_user could you try the code from the question? @ParitoshSingh tried it and also got the warning
 
@aneroid it no longer raises any warnings for me. (1.2.1)
 
c'mon now that's insane. will need to quote your previous message as proof that it did at least once :P
https://chat.stackoverflow.com/transcript/message/51651306#51651306
 
ok just to clarify, I am just pasting your code in a file and running it using different python versions from terminal
which obviously has its own pandas versions
 
yup, that's the right way - copy until the first astype(int) line which "should" raise the warning
for convenience, here's the full paste including the line which raises the warning:
 
ctrl + a code, ctrl + k
 
6:36 AM
df = pd.DataFrame({
    'Fruits': ['apple', 'orange', 'banana', 'pineapple', 'watermelon'],
    'Volume 1': [10, 20, 30, 700, 800],
    'Volume 2': [100, 200, 300, 7000, 8000],
    'Volume 3': [1, 2, 3, 70, 8],
    'Volume 4': [9, 8, 7, 6, 5],
    'Other': [-1, -2, -3, -4, -5]
})

df.loc[:, 'Volume 2':'Volume 4'] = df.loc[:, 'Volume 2':'Volume 4'].shift(1)
df = df.dropna()
# All okay so far, no warnings

# This next line issues a `SettingWithCopyWarning`:
df.loc[:, 'Volume 2':'Volume 4'] = df.loc[:, 'Volume 2':'Volume 4'].astype(int)  # warning
 
not getting any, maybe my I must have disabled warnings or something, so dont go by my word :D
 
6:55 AM
hi, I have a csv file, I want to find the row which has maximum value and print the row in which that value is appeared, this is what I expect:

csv file sample:
1, 5, 6, 7, 5, 2,
2, 8, 6, 4, 3, 9,
5, 9, 6, 8, 7, 3,
0, 4, 1, 6, 9, 4,

and if the code searches in the second column, the third row should be printed since 9 is maximum between values of the column.

5, 9, 6, 8, 7, 3,

I want to do this by pandas and work with column numbers not headings. I searched so much in the net and some propose using iloc functions, etc. but I could not make something work.
 
max value in a particular column yes? so, column 2 in this case for example
 
@ParitoshSingh exactly. kind of filter feature in excel spreadsheet.
 
@aneroid I have been trying to replicate, negative so far :/
 
can you write some code that sets those values up as a dataframe? makes it easier to have a starting point
hey anky!
 
Hello Paritosh :)
 
7:01 AM
I read the data from a csv file. part of my code is like this which iterates between many files:

read_file = pd.read_csv(
path + file,
delim_whitespace=True,
skiprows = 3,
usecols=[1,2,3,4,5])
 
ah not quite i was hoping for. no worries
 
read_clipboard maybe :P
 
@anky :)) read_my_mind better!
 
import pandas as pd
#an example of set-up

temp = """1, 5, 6, 7, 5, 2,
2, 8, 6, 4, 3, 9,
5, 9, 6, 8, 7, 3,
0, 4, 1, 6, 9, 4,"""

out = [row.strip(",").split(",") for row in temp.split("\n")]
df = pd.DataFrame(out)
# set-up complete

row_number = df[1].to_numpy().argmax()
print(row_number)
print(df.loc[row_number])
that kind of setup helps me help you, hope that kind of makes sense. basically "drop in" code that lets me create a dataframe.
anyways, for your real question, select your column, and take an argmax on the numpy array. (apparently series doesnt let me do an argmax directly). that's effectively your row number
 
@ParitoshSingh thank you! should I call numpy package as well?
 
7:07 AM
@enthu laurel, read_clipboard actually exists.
 
nope, no need for numpy. pandas is built on numpy, and to_numpy is one of the series methods it provides to access the underlying arrays directly
so it's internally using and giving you numpy arrays directly anyways
 
pandas has idxmax too :)
 
@ParitoshSingh fantastic. let me try it in my code and I will inform you how I progress. I am not so professional in python. need some time to dig in the codes. :)
 
ah nice. see if you can use idxmax, that probably would get the same result too.
 
@anky yes, idxmax and idloc were the functions I see in net by I did not succeed to bring them in my code...
 
7:11 AM
any reason why they went with a different name for argmax?
(or rather, does idxmax do something extra?)
df[1].idxmax() fails same as argmax did apparently. guess i dont understand why but can't be bothered to find out :P
 
ask the devs :D
yep, pretty similar, dont know the difference yet
need to check what the differences are to argmax from numpy. When I get some time
 
ah i see it
row label vs int position. so for custom index labels i presume we'll see a difference
 
for one, idxmax doesn't work with the new pandas extension types (Int64, UInt64, etc.) - capital I
 
@ParitoshSingh ahh yes, true.
I have to really upgrade my pandas. Missing out on a lot of things. or am I? :P
 
haha no clue. but i guess i was bothered enough to figure out the issue
import pandas as pd
#an example of set-up

temp = """1, 5, 6, 7, 5, 2,
2, 8, 6, 4, 3, 9,
5, 9, 6, 8, 7, 3,
0, 4, 1, 6, 9, 4,"""

out = [row.strip(",").split(",") for row in temp.split("\n")]
df = pd.DataFrame(out)
df = df.astype(int)  # i had not included this earlier. they were all strings. oops?
# set-up complete

row_number = df[1].argmax()
print(row_number)
print(df.loc[row_number])
argmax works just fine if they're actually ints
now theres probably a better way to make them all ints while reading the df, but anky probably knows that, i dont :P
 
7:25 AM
dtype is a part of read_csv /pd.DataFrame , but I suppose I would let read_csv infer it anyway mostly.
So I dont know :P
 
@ParitoshSingh I did this [[int(j) for j in i.split(',') if j]for i in temp.splitlines()] no pandas
 
yep that works!
 
What I was referring to is
temp = """1, 5, 6, 7, 5, 2,
2, 8, 6, 4, 3, 9,
5, 9, 6, 8, 7, 3,
0, 4, 1, 6, 9, 4,"""
from io import StringIO
pd.read_csv(StringIO(temp),dtype=int,header=None,usecols=[1,2,3,4,5])
 
7:45 AM
gotta run. Rbrb.
 
8:20 AM
this gets better: the message occurrence depends on if you run shift() and dropna() in the same notebook cell :-/ ipython or jupyter
@anky ^
link to SO question - https://stackoverflow.com/q/66327949/1431750
what have i stumbled in to...?
 
cbg
 
8:52 AM
good morning cbg!
 
cbg
 
9:48 AM
is numpy typing in good shape already? does someone have experience using it?
 
@aneroid How are you running this code? Is it just in a terminal or via something IPython related e.g. Jupyter/Spyder?
 
@MisterMiyagi no
 
If the latter, be sure that you're restarting the kernel between each of your tests
 
@MisterMiyagi recent thread with some hints (no pun intended) mail.python.org/pipermail/numpy-discussion/2021-February/…
 
10:03 AM
I'm supposed to talk a bit about meta-programming in python in a week or so. are there good examples out there somewhere of 1) a custom metaclass that does something useful and 2) a custom __new__ that does something which couldn't have been handled as easily in the __init__?
 
@AndrasDeak nice read, ty
 
because my cursory search came up with nothing of the kind
 
I sometimes (ab)use __new__ for the baseclass to act as a factory for its subclasses. __new__ searches through __subclasses__ and returns the first one that "works".
 
__new__ as a factory? is that code public?
 
Singletons and instance caches/pool rely on __new__ as well.
 
10:09 AM
Only do caching in __new__ if you don't mind __init__ being re-executed afterwards
 
ah right, because in __init__ it's too late. I think I used classmethods and stack inspection for that scenario up to now, using __new__ instead does sound like a good idea
thanks, that's a good one.
 
I have once used a Singleton implementation using a metaclass, ignore this if that is the same as "Singletons and instance caches/pool rely on` __new__` as well."
 
@Arne sorry, didn't find it. Could probably whip up an example if you need one.
 
no problem, I only really need one example to make a point.
I'm still curious of course
 
10:26 AM
This is super meta, but I when I implemented my own weakref.Proxy, I used __new__ to dynamically create a subclass of itself with the appropriate dundermethods. So then you can do things like len(Proxy([1, 2]))
 
user5556825
@aneroid thanks for the chart. then I would use #FFFF33 for comparison, since it is visually very similar to #FFFF00.
 
IIRC we used that to automatically create adapters based on URIs.
 
@MisterMiyagi oooh, I've never seen inheritance get inverted like this
I need to show this to my php colleagues, I bet this'll give them an aneurysm
@Aran-Fey That took me a while, but I think I get it
 
10:43 AM
@MisterMiyagi Number is effectively the facade pattern with automatic sub-type detection based on 'first that works'?
 
@Aran-Fey intuitively, I would have implemented __getattribute__ on Proxy to delegate the call. Is there a reason why that wouldn't work?
 
Yes, dundermethod lookup doesn't go through __getattribute__
 
@holdenweb Not sure if it's a facade. The returned object is not wrapped by Number.
 
drat
 
I'd say "Number is an interface, with automatic implementation detection ..."
 
10:48 AM
It quacks like a facade :P
 
now that got a chuckle out of me ;)
 
11:04 AM
Every funny bone deserves the occasional tickle.
 
12:03 PM
Hey, have you ever splitted django monolith into scalable microservices? What kind of approach did you choose? I do have an issue that i want to split some domain part into microservice, but i am coupled with django models and database.
 
12:29 PM
@roganjosh running it in jupyterlab and in ipython (and in colab)
@roganjosh see this question for more details and how to re-create the different behaviour : stackoverflow.com/questions/66327949/…
 
1:27 PM
Hey there Guys!!!
 
hello
 
2:21 PM
Hello :)
 
hello there!
 
2:41 PM
Cbg all, I found a documentation to tkinter and I wanted to put it out there so more people can reach over it, because I think most people refer over the main website, which is not that well written and www.effbot.org is out of order too. So would making a Q&A style question to share this be offtopic for the site?
 
@CoolCloud it would be off-topic, but the people here in chat would probably appreciate the tip
> Some questions are still off-topic, even if they fit into one of the categories listed above:
> 4. Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
and the link to the resource could eventually go stale, like with effbot
 
perhaps it could fit into the tag wiki?
 
Yeah, that's a good idea. Although we should probably vet it first.
 
@AndrasDeak Or I could add it to a repo? and share that link?
 
@CoolCloud I don't see what that would change
 
2:46 PM
@AndrasDeak I wouldnt take it down ;)
 
Ah, I see. No.
 
Lol ok, I will edit the tag wiki then
 
No.
If the resource is crap we don't want that added to the tag wiki.
 
It is been a huge boon to me. Anyway could you tell which is better one or two or three
 
I think you mean "boon"
bane is something that's bad for you :)
 
2:50 PM
@AndrasDeak I am gonna pretend that never happened....Too early for embarrassments.
 
"1995 is calling, it wants its user interface back", is that site making fun of the very thing it documents?
 
@CoolCloud nothing to be embarrassed about, both words are very rarely used
 
@python_user Which site is that
 
"three", there is a pic on the right
 
Tried to be funny there I guess.
 
2:54 PM
cbg
 
So.. post or no post :p
 
@CoolCloud Will you keep asking the same thing until you get an answer you're happy with?
Or you mean post in the tag wiki?
 
Yea the wiki tag
 
Even for the latter I'd be more confident if users like @Kevin had a time to take a look at the resource
 
Its been out there for 8 years and I'm pretty sure its good enough. But ok.
 
3:06 PM
@ParitoshSingh thank you @ParitoshSingh and @anky, I probably do it with idxmax function
 
```
In [159]: result
Out[159]:
[['10.0.11.100', 'N1', 'N2', '10.0.12.100'],
['10.0.11.100', 'N1', '10.0.1.6', 'N3', '10.0.13.100'],
['10.0.11.100', 'N1', '10.0.1.6', 'N3', 'N4', '10.0.14.100'],
['10.0.11.100',
'N1',
'10.0.1.6',
'10.0.1.14',
'10.0.4.6',
'10.0.22.10',
'10.0.22.100']]

In [160]: pprint(result, width=100)
[['10.0.11.100', 'N1', 'N2', '10.0.12.100'],
['10.0.11.100', 'N1', '10.0.1.6', 'N3', '10.0.13.100'],
['10.0.11.100', 'N1', '10.0.1.6', 'N3', 'N4', '10.0.14.100'],
['10.0.11.100', 'N1', '10.0.1.6', '10.0.1.14', '10.0.4.6', '10.0.22.10', '10.0.22.100']]
Can anyone tell me how do I change Ipython's pprint's default width?
 
3:33 PM
Nevermind, found it.
 
3:53 PM
I want to start a hotel chain called Async, just so that I can make it a rule that guests checking in should be greeted as "Welcome to Async, we've been awaiting your arrival"
 
@inspectorG4dget or just for the laughs that guests may not necessarily arrive, check-in, check-out and depart in that order? :p
 
@JonClements hmm... I see a possible segway into Hotel California: you can checkout anytime you like, even if you haven't checked in yet. Wanna join me on this venture?
oh, while I have your attention you fine folks, I have a rather odd question. We use github at work and we have a lot of issues up on the board. So lets say I've closed an issue in a commit in a different branch. That branch is currently in PR, but the PR hasn't been approved/merged yet. So the issue remains open (even though it remains to be seen that any work is left to be done on it - that'll come from the PR's comments)
So when I look at the list of issues to figure out what I want to work on next, I see issues that I've already closed (but aren't yet actually closed because the PR hasn't been merged yet). Any way to filter these out?
 
4:18 PM
That's an interesting question. The way I usually work, the issues are in a separate system (Jira) from the version control. Yours seems highly coupled.
 
hmm... thanks. That actually helps
 
I would decouple. Even if it's a list of your priorities on paper.
 
@inspectorG4dget I would assume that any issue being closed by a PR are owned by / assigned to the PR author. So just filtering for unassigned issues should work.
 
@Arne Metaclasses are usually recommended to be avoided because when you want to use multiple inheritance and parents use different children of metaclasses, Python refuses because it has no way (as of now anyhow) to determine which metaclass to use.
On the other question: One use for __new__ is when subclassing immutable Python objects, where you can't use __init__.
This is probably covered sufficiently elsewhere, but when defining __new__ you need to explicitly pass cls to the __new__ lookedup on super(), i.e. super().__new__(cls).
That's because __new__ was internally created as a staticmethod instead of a classmethod, so it doesn't get cls implicitly from super like you might expect.
Back to the metaclass question, if you're using custom metaclasses in mixins and run into the problem I described above, you'll need to rectify the metaclass inheritance tree somehow. e.g., if you have one mixin that uses ABCMeta and another mixin that uses, idk, CustomMeta, to use them together, the simplest approach would be to have CustomMeta subclass ABCMeta.
If I were giving a short talk on how to use metaclasses, I'd show how to use ABCMeta, describe the problems with metaclasses as I discussed here, and recommend they avoid it. Other ways of doing metaprogramming are: 1) like __new__ or __init__, can be done with constructor functions outside the class definition, and 2) class decorators can modify classes after they've been defined.
I'd focus more on those 2.
 
4:50 PM
@CoolCloud I have found the New Mexico Tech docs useful in the past, particularly because they described the callback substitution codes for entry validation events, when i couldn't find them anywhere else on the internet, including on effbot.
The tcl docs are official and thorough, but the api is described with the command line interface in mind, so it's not always easy to convert it into something that Python understands. If the Tkinter designers made any design choices independently of Tk, then you're not going to find information about that there
 
@MisterMiyagi unfortunately not. They're typically assigned "right away" to signal "I am/will_be working on this"
 
I'm not too familiar with TkDocs, but just poking around I like the looks of it. I'll give it an A for design just because it looks like it was written this century
I'll have to withhold a perfect score if they don't warn about some of the more common gotchas, for example the PhotoImage garbage collection surprise
 
@inspectorG4dget That's unfortunate indeed. A tag would be a simple fix then. Could probably make a GitHub action to tag automatically as well.
 
5:17 PM
@Kevin I dont think it is mentioned in there though.
 
TkDocs' About page basically says "we're not going to discuss language-specific quirks" so I guess I can understand why they wouldn't mention it
I notice TkDocs and the official TCL documentation are both already mentioned in stackoverflow.com/tags/tkinter/info. If the question is "should we also add a link to the NMT docs?", my concern is more about link rot than the document's reputability
The NMT docs already vanished off the web once when NMT redesigned their site. The mirror you linked is nice, but I don't think this anzeljg.github.io guy is, like, officially affiliated with NMT, or obligated to maintain the page at all
 
5:35 PM
that NMT mirror link is also there? or was it edited recently?
 
Oh, there it is. I missed it because the link text doesn't contain the letters "NMT"
So now the answer to "should we add these links to the tag wiki?" is "no, because they're already there" :-P
 
6:19 PM
ever though about getting a 100 more rep? 69k nice
 
@Kevin thanks
 
6:39 PM
hm, everytime I look at tkinter I think to myself: why isn't that async? boggles the mind...
 
7:00 PM
@MisterMiyagi Thanks. This is very helpful. I was basically going to just hold my breath until we got our licenses for project management tools (like JIRA). But tags/labels are a very valid and feasible solution until that happens
 
7:39 PM
@MisterMiyagi It is async, but using callbacks, (async as in event-driven, rather than async as in keyword/coroutines) isn't it?
 
That's how it was done back in the 80's
 
It was good enough for grandpa ...
I imagine the async programmer's Siberia is a place where you endlessly glue together code built on top of different event loop paradigms. [shudders]
 
@holdenweb it is indeed. just lacks the magic sprinkles to be 20% cooler.
 
 
2 hours later…
9:42 PM
is there some efficient way to conjure a numpy array in Cython? all I've found just calls a numpy constructor the Python'ish way.
 
I only know there's a page called cython for numpy users, does that not address this?
Ah, no. I read that and it was not about constructing new arrays
 
they only call np.zeros, which is all ugly yellow poo in annotated mode
 
You mean linter?
And even if you add a dtype?
 
10:06 PM
the cython -a output. "Yellow lines hint at Python interaction."
 
ah, OK, a cython thing
 
do you think wiggling the rear view mirror might help?
 
Maybe. Or adding a dtype.
ah, no, the yellow is right there in the tutorial
*moves rear view mirror back*
OK, I guess we could look at scipy code
I've found some np.empty initializations...but they are yellow
 
hm. if even scipy is fine with that, I could do some Knuth Culting instead of worrying.
 
I looked at github.com/scipy/scipy/blob/… and friends
But since there's a C API for numpy... I wonder if you could circumvent the interpreter in some easy way
but for what it's worth numpy itself is also OK with the yellow numpy.org/doc/stable/reference/random/…
perhaps the idea is that instantiating arrays is not the bottleneck
 

« first day (3783 days earlier)      last day (1152 days later) »