« first day (3355 days earlier)      last day (1598 days later) » 

12:16 AM
@Jason which post? the url which I've shared is for different thing
 
@αԋɱҽԃαмєяιcαη I am talking about this "Hi Guys, I am trying to scrape booking.com data for my personal project. I can able to retrieve the hotel name, ratings and location. I need the hotel description as it is the main field for my text mining. Each hotel description on different pages. I need to click each hotel name and it opens in the new window and I have to scrape the description. I am using Selenium web driver. I can able to take one hotel description, but I need to extract all the hotels automatically.
 
@Jason I've sent for you a request for chat
 
@αԋɱҽԃαмєяιcαη Can you please resend it?
 
I joined
unable to see you
 
12:18 AM
i too
 
joined sent message
 
1:06 AM
@ParitoshSingh Thanks for introducing me to James Powell. His public speaking is really exceptional for technical subject matter, I'm pretty jealous. Though, I did get a decent laugh from following on to another video here
 
 
3 hours later…
4:24 AM
@roganjosh he's typing too fast
 
Sam
HI there! If I'm doing something like this: v[1:-1, 1:-1], is there a way to define "1:-1, 1:-1" as "CURRENT"?
 
5:04 AM
You mean like CURRENT = slice(1,-1), slice(1,-1)?
 
 
1 hour later…
Sam
6:07 AM
Perfect. Thanks Aran!
 
6:35 AM
cbg
 
Interview question, String compression: Write a method that takes in a string such as aabb and outputs a2b2. (aabbaac yields a2b2a2c), any ideas?
 
7:17 AM
this seems pretty trivial if you just scan through the string and compare the current to the next character. What problem do you have solving this exercise?
 
yeah you can treat string as a list of char, as in string in python are iteratable so
I have a directory structure
/project
/project/hello/bye.py
/project/ok.py
in ok.py I want to import bye.py so:
from hello import bye
this works when I run ok.py
but when I use a setup.py to install the project using pip
and do from poroject import ok, the code breaks saying no package named hello
 
# basically you need to write this one nicely
def encode(a:str):
    return ''.join(itertools.starmap(lambda k, g: k if len(g) == 1 else f'{k}{len(g)}', map(lambda kg: (kg[0], list(kg[1])), itertools.groupby(a))))
writing this in a way suitable for an interview answer is left as an exercise for the reader
 
yeah I wouldnt use lambda
it makes it less readable
 
Yes, both starmap and map can be re-written as comprehensions or loops.
@WantingtobeanAndroidDevelor that's because the package is named project.hello
 
so I would have to do from project.hello import bye ?
 
7:30 AM
yes
 
even in ok.py that is already in the project
 
or alternatively use relative imports, i.e. from .hello import bye
 
but when I run the code with from project.hello without installing it as a package it throws error
yeah sure is that what the relative import is for?
 
you have to decide whether project is a package or not. If yes, always run package.ok. If no, always run ok.
you can run a submodule of a package as python3 -m package.ok
 
I see thats annoying
because I get:attempted relative import with no known parent package
so basically I have to tell the interpreter that its a package?
 
7:34 AM
if it is part of a package, you have to execute it as part of a package, yes.
 
I see
what IDE do you use btw?
 
consider whether the executable should reside in the package in the first place, though.
There's also __main__.py to make the package itself executable.
 
what do you mean?
 
And entry_points/console_scripts to create a separate executable.
@WantingtobeanAndroidDevelor I mean that I have no idea what you want to do. I can only tell you what you could do.
 
but then would they be included when you do setup.py install
I just want to write something that is easy to install so that everyone in the team can use the code
Doesnt everything have to be a package for it to be included as a package, when you do setup.py install?
 
7:59 AM
thanks @Mis
thanks@MisterMiyagi
if you follow the default python convention you would have something like
package_name/package_name.py
when you import this you would have to do something like:
from package_name import package_name
which looks stupid, how do you prevent this?
so that its like import numpy
 
I need help with this, first time to see something like that. repl.it/@AmericanY/Puzzle
 
Are you using __init__ files @WantingtobeanAndroidDevelor?
 
Init files get executed on imports. you can use those to "fix/shorten" imports by defining the from package_name import package_name imports there. That's essentially how numpy does it too actually
 
oh wow cool
I never knew that
 
8:13 AM
There's variations around that concept, but that's the gist of it. manually expose what things you want imported in the init, and modify the import paths there as you see fit.
 
@WantingtobeanAndroidDevelor erm, I haven't seen this pattern recommended ever.
 
@roganjosh :) Yeah, i was really impressed with his presentation skills. Shame i can't access that link right now, here's to hoping i don't forget about it later!
 
what is the name for this technique so that I can google
 
Hm, im not aware of any names for it per se
it's just imports at the end of the day, same as usual
 
user10984358
8:48 AM
@reydonsancho print("".join(map(lambda x:x[0]+str(len_x if (len_x:=len(list(x[1])))>1 else ''),groupby(t)))) looks like this works as well
 
user10984358
a smaller version of what MisterMiyagi said
 
9:26 AM
thanks @ParitoshSingh
 
10:25 AM
@αԋɱҽԃαмєяιcαη you can inspect the page source, and then just ctrl+F to get an idea of what's going on. The items you're missing have extra symbols before the end of string, and so they don't match the pattern. It's lame, but yeah.
 
10:42 AM
@ParitoshSingh i already figured it out and posted an answer for the OP since an hour
0
A: Broken HTML tags - BeautifulSoup

αԋɱҽԃ αмєяιcαηimport requests from bs4 import BeautifulSoup import re for num in range(14, 25): r = requests.get(f"http://www.asmi.com/index.cfm?GPID={num}") soup = BeautifulSoup(r.text, 'html.parser') names = list(dict.fromkeys([' '.join(items.split()) for items i...

 
i see.
 
the website is completely crab and out of date
 
11:16 AM
cbg
brief cbg
 
Umm.... /me makes whatever noise unicorns make...
 
11:47 AM
:D
 
 
3 hours later…
2:30 PM
Hello Every One ! I am working on a data set where 90% of data is categorical , I want ti apply unsupervised Learning with categorical columns , what should be the approach . because with numerical column i can do a pca and any clustering technique to understand the pattern . But in case of Only categorical what should be technique to us . please guide me on this thank you
 
out of the categorial data, how many of the columns are ordinal?
 
2:53 PM
okay, for the first time in my life I've used view spoiler (with success) for AoC day 23
 
3:09 PM
@AndrasDeak that's the spirit!
 
I didn't actually expect it to help :)
then again I also didn't expect to get it right
 
3:20 PM
@ParitoshSingh 10% would be ordinal
 
3:32 PM
without even looking at the spoiler, the fact that mr miyagi replied to your message makes me think it was something with async :P
@NabiShaikh in that case, it seems like you don't have a lot of choices. A few google searches seem to indicate perhaps K mode clustering as your go-to algorithm. You may also want to explore some mechanism of turning your categorical variables (perhaps after some aggregation) into numerical ones, and it would have to be better than just one hot encoding. Perhaps target encoding or something along those lines. Explore that if k mode doesn't do it.
Disclaimer: this is definitely not something i've ever implemented myself though.
 
4:11 PM
Scott C Reynolds on December 23, 2019

Marla was dead to him, to begin with. There was no doubt about that. Marla had been his best partner, the back-end architect yin to his senior front-end engineer yang. But she quit a few weeks ago, leaving Stu, possessed of only the faintest knowledge of services (both serverful and serverless), to implement the new API.

Stu watched as the Slacks dwindled to a light trickle of GIFs and his coworkers left for the holidays, strains of the favorite joke of office comedians around the world filled the open floorplan. Yes, I will see you next year Tim, because it is almost New Year’s. How droll, Tim. How droll. …

 
It may have taken me the whole day, but I finally came up with a proof that c < 0 implies |c| > 0. Lol.
 
@Dair umm... c = -0.1 seems to be a counterexample
 
...?
 
@inspectorG4dget How so?
As an expert in absolute values I can assure you that it is not a counterexample.
 
lol
I will admit, im having a really hard time imagining a proof of something like that
i'd have presumed that "by definition" |c| > 0 is true for all c != 0
 
4:19 PM
not by definition, but yes
 
oh damn! I read |c| > 0 as |c| > 1. I think I've checked out. Ignore me
 
lemma le_zero_abs_pos (c : ℝ) (hle : c < 0) : |c| > 0 :=
begin
  rcases lt_trichotomy c 0 with hc|hc|hc,
  have ne := ne_of_lt hc,
  rw gt_iff_lt,
  rw abs_pos_iff,
  exact ne,
  have ne := ne_of_lt hle,
  exfalso,
  exact ne hc,
  have ne := ne_of_lt hle,
  rw gt_iff_lt,
  rw abs_pos_iff,
  exact ne,
end
That was the proof I came up with.
 
@inspectorG4dget Besides, the universe Dair's working in only has integers, IIRC.
 
what language is that?
 
That seems like something above my pay grade, so i'll take your word for it as the room6 expert in absolute values.
 
4:21 PM
@PM2Ring ah. I missed that part
 
@PM2Ring I'm doing stuff in the incomplete real number game. c : ℝ
 
@Dair Ah, ok.
 
@inspectorG4dget Lean.
 
Dec 19 at 14:53, by Dair
@PM2Ring Iirc you liked puzzle games. In which case I think you should check out this unique math game. definitely one of the more unique math-CS intersection games. Surprisingly unlike CS competitions.
@inspectorG4dget ^ That game.
 
@PM2Ring Although speaking of that, I got really annoyed because you can't just implicitly cast from natural numbers to integers and to real numbers because they are all internally extremely different.
There is also an incomplete real number game
 
4:23 PM
right on! I might have to check that out over the holidays
 
@PM2Ring bookmarks nice!
 
@Dair Here's a cute integer thing I noticed a few years ago while messing around with square roots and Pell"s equation. Obviously, 18 - 13 = 5. Not so obviously, 18^2 - 13×5^2 = -1. That is, 18/5 is a good approximation for sqrt(13). I suppose I should do a search to see if there are other numbers with that pattern...
3
 
You should! Anyway, I need to go rbrb.
@ParitoshSingh One last thing: If you think this is obvious, in the natural number game, n * 0 = 0 is considered obvious, but 0 * n requires induction to prove lmao.
 
Interesting! I am not too familiar with the nuances of mathematical proofs, but i know there's a lot of things that aren't "assumed" true, but are proven first. It's just that i was mistakenly assuming that "absolute" wasn't one of them
Which does make me wonder, formally what is absolute defined as.
 
4:36 PM
for what it's worth commutativity of real multiplication is pretty fundamental
 
See, now i'd have been using commutativity to prove that proof. Definitely not cut out to be a mathematician sigh :P
It's like you have to be really careful not to use the things you take for granted when proving something that's so fundamental in a way
 
yeah, if the whole game is about building up real arithmetic you have to go step by step
 
Oddly enough, i speculate that writing a programming language might be a very similar experience.
 
Beware floating point arithmetic is not commutative
 
Huh, is that true?
 
4:41 PM
No
 
kk, thought as much, i couldn't imagine why it would be true.
 
It's not associative.
 
@AndrasDeak Which is somewhat painful if you have to start from the Peano axioms :)
 
@PM2Ring yeah...
@ParitoshSingh at least I don't think so
 
My mental model of floating point arithmetic is essentially "the number that you think you're using always resolves itself to something that is slightly off. But it's always consistent in what it resolves to". So swapping two numbers around shouldn't matter.
 
4:44 PM
@AndrasDeak I guess it makes an interesting game, though. A bit like coding in a minimalist esolang like Brain*
 
Would love to be corrected if im wrong though.
 
How about using arbitrary precision arithmetic?
 
@ParitoshSingh there is a difference between "small + small + ... + large" and "large + small + ... + small"
in the former cases, the small values may accumulate to a large one. in the latter case, each may get swallowed by the larger value.
 
Related: catastrophic cancellation en.wikipedia.org/wiki/Loss_of_significance
 
Im starting to lose my mind over here.
ConnectionError(<urllib3.connection.HTTPConnection object at 0x7fbe85625d90>: Failed to establish a new connection: [Errno 111] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7fbe85625d90>: Failed to establish a new connection: [Errno 111] Connection refused): ConnectionError
 
4:49 PM
Oh, huh that's interesting
I'll admit I wasn't even thinking of more than 2 terms for some reason
 
The elastic search keeps throwing this error
 
But yeah, with just 2 values, floating-point addition and multiplication are commutative
 
es_host = 'search-es-twitter-demo-ffmbzmck5x6vnolbkwmzcv7r5u.eu-central-1.es.amazonaws.com'
es_port = 80
es_bulk_chunk_size = 1000  #number of documents to index in a single bulk operation
Does anyone have experience with AWS
 
Hello guys, more a design question than python but any help would be appreciated. I am currently working with a friend and we needed some sort of factory, and he came with an implementation that works in our context but does not feel right to me (pastebin.com/xwuiciph) I am not an expert but I feel like there is some meta problem going on as methods usefullness seems related to the initialisation. Am I being an a** or is there really a problem here ?
 
What's surprising to me is that even (0.1 + 0.2 + 0.3) == (0.3 + 0.2 + 0.1) gives False on my machine. I wouldn't have considered the problem to manifest itself that quickly.
But in hindsight, it makes sense, you need to take two values and store the result before proceeding.
 
4:53 PM
Crazy. The only way is to remedy that exactly is to use fractions.
 
aye, or one of the other ways of circumventing floating points, such as decimal module and so on
 
@ParitoshSingh absolutely correct ..need to try and search ..
 
@JulienBreuil I can tell you that that code is bad, but since I don't know what problem you're trying to solve I can't tell you how to do it better
 
@ParitoshSingh yeah, or 0.1 * 3 != 0.3
 
well, I can tell you how to do it better, but not how to do it well
 
4:56 PM
@Aran-Fey Ok I will try to come up with some sort of abstract of the problem but i need to think about it
 
One important thing is to realise we all go through the stage of doing something a certain way, and realising later why it's not ideal and how it could be improved. Don't forget to actually appreciate your colleague's attempt at providing a solution that works.
 
@Ḿűỻịgǻṇącểơửṩᛗ Well, that's one way of dealing with the problem. :) But coders should have some understanding of what's going on in floating-point arithmetic so that they can use it properly and not be bitten by it.
 
@JulienBreuil misc. improvement tips: Instead of if x == 'foo': return self.foo, you can do return getattr(self, x). And if you're planning to use a manager object more than once, you shouldn't pop anything out of kwargs
 
@ParitoshSingh Well, there are 2 things going on there: the intrinsic limitations of any floating-point system, and the fact that simple decimals are generally not simple in binary. 0.2 decimal is 1/5 = 3/15, so as a binary number it's 0.00110011...
 
Aye, makes sense!
 
5:04 PM
@Aran-Fey Thanks that it really interesting in the context. In his implementation he would only use instanciate the manager for one action. So in his use case poping is Ok but at the same time I feel wierd havind a class with multiple methods but only one would be used based one the action selected at instanciation. It looks like a wierd factory but I am not enough experimented to tell if it is ok or not.
 
A class that's instantiated for only one use sounds like a massively overengineered function to me
Why do instantiate -> call method when you could just do call function instead?
 
On the early machines I first programmed, the CPU only did integer arithmetic. You had to call library functions to do floats. Of course, that was invisible if you wrote in a high level language. But if you were coding in assembler, you had to deal with it directly.
 
coding in assembler shudder Im glad someone did that so i don't have to. ;)
 
We are trying to respect some SOLID guide lines so one class should only have one responsability. Here the manager is supposed to return the correct command based on a name and arguments which is only one responsability. While the client class that instanciate the manager, has the role of executing the command at the right place.
 
@JulienBreuil sounds like you need a dict of functions, not a class
also, functools.partial helps for the kwargs.
then again, if you dispatch on action only once, doing so right away would be way easier.
def get_cmd(action, **kwargs):
    if action == "top":
        return Command(name="app.cmd.foo", kwargs=kwargs)
    elif action == "bot":
        mode = self.kwargs.pop("mode", None)
        if mode is None:
            return Command(name="app.cmd.bar", kwargs=kwargs)
        return Command(name="app.cmd.bar2", kwargs=kwargs)
 
5:21 PM
@JulienBreuil Is that just a simplified example? Does the class in your real code have more than the 3 command methods?
 
The problem would be that some action required a harder work to determine the command to return plus having in future 20+actions would make get_cmd too hard to maintain.
thanks for the functools i did not know about it
@PM2Ring yeah it have more than that and need to be able to scale/extend. Later we could have multiple manager and some would have 20 commands
 
Ok. With 20+ actions, and more complicated stuff involving mode etc, the if..elif..else will get large. So maybe the class makes sense. OTOH, as Mister Miyagi said earlier, you can make a dict of functions. That could also get messy though, depending on what you need to do with mode, or some of the other kwargs.
 
5:36 PM
I think you gave me good paths to explore and more clues on what to focus on. Thank you guys
 
Complexity O(n) or O(n^2) ?
 
2 days ago, by Andras Deak
@MikaelKen please see our code formatting guide for chat and practice in the sandbox if necessary
 
depends on what profile1 and profile2 are. Also, take a look at the code formatting guide
 
Sorry again ... :)
 
you don't have to be sorry, you just have to actually take the five minutes to figure it out
Sandbox.
 
5:46 PM
 for k in profile1:
        if k in profile2:
hope this is right?
 
if the indentation you see matches your actual code then it's right ;)
 
both are lists, and I was wondering about time complexity
 
@MikaelKen If this is related to what you were doing the other day, there's probably a way to do it more efficiently with sets.
 
the loop O(len(profile1)), the if is O(len(profile2)) each time
 
so more generic would be O(n1+n2) ?
O(|n1|+|n2|)
 
5:49 PM
no, multiplied
 
not addition. "for each iteration" you're doing O(n2) work.
 
using a set for profile2 would make that O(1)
 
Membership in a set is O(1). Membership in a list is O(n) because the list has to be scanned linearly to find the item. On average, you have to scan halfway through the list to do that.
 
5:50 PM
of course you'd want to pre-create that set outside the loop, only once
 
@MikaelKen What type are the list items?
 
strings
 
Great. You can easily make a set of strings, because strings are immutable & hashable.
 
yeah but i cant have a set, since they are not unique
 
@MikaelKen that doesn't matter for testing membership
 
5:54 PM
It looks like you want to perform some operation for each string in profile1 if that string's also in profile2. So you could find the intersection of those two sets.
 
@MikaelKen consider the line if k in profile2: does it matter to you whether k appears once, or twice, or 10 times in profile2?
 
@MikaelKen Oh. So if a string is repeated in profile1, and also present in profile2, does that mean you need to repeat the action for that string?
 
wim
6:24 PM
@AndrasDeak np.argsort is O(n^2) worst-case, right?
 
uuh, no idea
 
wim
@AndrasDeak huh, it didn't really call for coroutines as far as I could see, but that's cool ...
 
it has timsort now, does that help?
@wim for some reason multiple iterative approaches failed, so I got desperate
 
wim
waittttt a minute, aren't you just using generators?
 
Ones that you can send to, yes. I was told that makes them coroutines.
oooh wait a second
 
wim
6:27 PM
didn't push code?
 
yeah, I may have removed the coroutineness along the way :D False alarm, @MisterMiyagi
 
wim
don't see any coroutines there github.com/adeak/AoC2019/blob/…
 
yup, you're right
 
wim
rats
 
I was so surprised that what I had worked that I didn't notice that it was no longer a coro
 
wim
6:28 PM
got me all excited for nuthin'
 
guess I should rename it
@wim sorry :P
 
wim
when I was writing my hacky code I was even thinking "it would be cool if someone bothers to do this async"
 
at least I'm back to the familarity of "I've never (successfully) used coroutines"
 
wim
for sure there will be some egghead on reddit that did it with select
 
OK, removed the lie
 
6:46 PM
Wow!
6
Q: Update: an agreement with Monica Cellio

Sara ChippsStack Overflow and Monica Cellio have come to an agreement. We believe that Ms. Cellio was not acting with malicious intent. We believe she did not understand all of the nuances and full intent and meaning of our Code of Conduct and was confused about what actions it required and forbade. We ac...

 
wow
> In recognition of the mistakes that led us here, we invited Ms. Cellio to apply for possible reinstatement on all six sites following our new reinstatement process. Ms. Cellio expressed concerns about the new process and has not applied.
interesting replies too
having read it twice: less "wow"
 
Well, it's a lot more progress on this front than I was expecting.
@ReinstateMonica-GoodbyeSE I want to be reinstated (more specifically, for the removal to be reversed). — Monica Cellio 4 mins ago
 
well, Monica did raise $25k for legal help
making an infinitesimal step in the right direction should be worth a lot in dollars now for the company
 
Sure it's not a perfect outcome. But I wish the general MSE response was a little more positive about it.
 
6:57 PM
SX is hiding behind legalese instead of making a genuine effort to rectify mistakes
 
all they've had is legal ever since they defamed Monica in the press
can't really backtrack from there without opening up to lawsuits
nobody would sue them, but they can't take the chance of admitting they did anything wrong
 
That. I assume that both SO Inc & Monica are restricted in what they can say right now, due to lawyer stuff.
 
both have explicitly said that on the meta, yeah
 
So, uh, I'm trying to make a super thin asyncio irc client. So I was wondering, would implementing asyncio.Protocol be a good way of doing that? The docs go to a lot of effort to state that you shouldn't use asyncio.Protocol, but never say when you should use it.
 
wim
+43/-43 LOL
 
7:02 PM
@wim tinkeringbell had a good point about voting on that question
oh well
 
wim
does numpy have something like np.random.shuffled
like np.random.shuffle but returns new obj (analogy with sort, sorted)
 
7:18 PM
numpy.random.permutation apparently.
 
that ^
it will only shuffle along the first axis, but so will np.random.shuffle
and I think current numpy prefers rng = np.random.default_rng() and then rng.permutation etc. If I recall correctly the np.random namespace is legacy random now
 
wim
@ParitoshSingh bingo
now, here's the reason I was asking
import numpy as np

n = 1000
points = np.random.randint(n, size=(2, n))
shuffle = np.random.permutation(np.arange(n))

%timeit points[:, np.argsort(shuffle)]
%timeit np.dot(points, np.eye(n, dtype=int)[shuffle])
will #2 ever get faster than #1 ?
with small arrays, they seem to be similar. with bigger arrays, the argsort is winning.
is that O(n log n) vs O(n^2) or vs O(n) ?
 
7:41 PM
time this too:
invidx = np.empty_like(shuffle)
invidx[shuffle] = np.arange(n)
res2 = points[:, invidx]
 
Can anyone help me get a python cgi file running outside of cgi-bin in Apache2?
I already asked a question that got my script working, but I need it under a particular url stackoverflow.com/questions/59338964/…
 
8:03 PM
What am I missing here? Why the need for np.argsort in points[:, np.argsort(shuffle)] and not just points[:, shuffle]?
 
wim
Because, the permutation is the input here
 
A permutation of indices that can't repeat and can't exceed the length of points, though?
 
wim
Yes. Assume the points and the permutation are already given, you want to find the fastest way to rearrange columns as specified in that permutation
 
Which is what my example does. You already get a shuffled output, I still don't see why you then need a further np.argsort()
I can see how they are different, but if you're just using np.random.permutation(np.arange(n)) simply to get a "random" ordering of column indices (which it does give), and you don't care what that ordering is, then I don't see what np.argsort adds to the mix. It's already a valid, shuffled, list of indices to rearrange with
(provided of course that my initial caveat is correct that the output of shuffle is a) a non-repeating set of indices and b) doesn't exceed the length of the points array, which both hold here. If that wasn't the case, then you'd need argsort to avoid an index error etc.
 
8:19 PM
@wim what I suggested is 2x faster for n=1000, 4x faster for n=10000 and 4.5x faster for n=100000
 
Exactly the same timeit characteristics of points[:, shuffle]
 
8:41 PM
that's reasonable
@AndrasDeak faster than argsort I mean
@roganjosh he wants a specific inverse permutation for an existing shuffling order
imagine trying to undo points[:, shuffle] later
 
My take was that you wouldn't want to, because the requirement was to make a new object but I guess I've misread.
 
wim
9:28 PM
@roganjosh It's a little hard to explain but Andras is right (kind of like an inverse permutation)
Was trying to improve upon Rearrange columns of numpy 2D array for context
@AndrasDeak nice. I will edit it in.
 
do time it yourself too, though
 
wim
The last sentence of the question suggests O.P. is already aware that permutation matrices are not going to work, so I guess I can just remove that part anyway
 
grrr, seems I can no longer use just alt+shift as a key binding on gnome
okay, found it hidden deep in gnome-tweaks née gnome-tweak-tool
 
I find it really curious that you've both gone with an inverse-permutation-like interpretation from the question: "Is there a way to change the order of the columns in a numpy 2D array to a new and arbitrary order?". I'm happy to assume that, in the general case, my reading of this problem has been incorrect, but for a breadth-first search in one of my own problems, I'd never want to recover the original. I just want fast randomisation.
 
I've only interpreted wim's code
@roganjosh OK. So looking at OP's question: they exactly want an inverse permutation. "I want item k to have position a[k]" is exactly that. Instead of knowing where indices start from, OP knows where indices end up.
@wim what do you mean when you say "An in-place permutation is not possible"? With O(1) memory?
 
wim
9:44 PM
They meant a view if possible
like a permutation stride trick
which is only possible in a handful of special cases
 
Then I'd rephrase that, because "is a view" and "is in-place" are very different things
 
wim
not sure how to word it - you can edit directly? stackoverflow.com/a/20265477/674039
this is "in-place" but it's still copying the entire array
I guess that is O(n) memory, in other words.
 
what's "in-place" about it? (without assigning back to a[...])
 
wim
I thought I did assign back, LOL
you are right, there is nothing in-place about it
uff, long day
Your code is O(n) space and O(n) time, right?
Is this even called "fancy indexing" ?
 
yes and yes and yes
the offical name is "advanced indexing", but fancy is the colloquial name
 
@AndrasDeak Got it now with some extra playing, thanks :)
 
no worries
 
wim
yes, it's a little confusing, but Andras explained it better than I could
 
I was also being a bit slow :P
 
wim
the kicker is that in the original revision of the question, it was possible with a stride trick
and, of course, in my original answer I used a stride trick
too much M in the MCVE
 

« first day (3355 days earlier)      last day (1598 days later) »