Closed alysivji closed 7 years ago
thanks @alysivji ! I'll take a look at the code tomorrow - in the meantime, if you could update the docstring to reflect the change, i'd appreciate it!
thanks @alysivji!
i took a quick look at the code and it looks good, although i haven't actually tested it.
question for us to think about: are there any strange group/legend cases to consider here?
Updated the docstring.
Just one thing I noticed is that sometimes groups change when rerunning code blocks. So Group 1 isn't always Group 1, sometimes it might be labelled Group 2. That might be caused by the set function. Not too sure if set keeps order the same each time.
ah, yes - i've run into that annoying issue before. i think you can fix it by replacing set
with:
sorted(set(group), key=list(group).index)
this should make the order consistent
I changed my code and now when I try to run the following:
import hypertools as hyp
import scipy.io as sio
import numpy as np
data = hyp.tools.load('weights_sample')
group=[]
for idx,i in enumerate(data):
tmp=[]
for iidx,ii in enumerate(i):
tmp.append(int(np.random.randint(1000, size=1)))
group.append(tmp)
hyp.plot(data, '.', group=group, legend=True)
Legend order changes around each time it is run. How to proceed?
hmm, ill take a look at it and get back in a sec!
ah! the issue is that int(np.random.randint(1000, size=1))
is generating random values, so we would expect the legend to also be random (they are different numbers each time)
I tested the ordering issues after changing set(group)
to sorted(set(group), key=list(group).index)
and it seems to be the same every time. want to commit a change, and then i'll check this over and merge?
Ahh yes, that makes sense. I need my coffee =)
Updated the PR. It was fun getting to know this lib yesterday. Definitely will be using it for some analyses.
Awesome, thanks for contributing your time! We appreciate it :)
If you have questions, or comments about how to make the code better, feel free to share as things come up, either on the gitter or issues
lgtm!
To close https://github.com/ContextLab/hypertools/issues/97
Moved the handle legend block and used the results of the group data block to calculate the legend, as required.
Let me know if this works or if you need me to edit something.
Thanks