tctianchi / pyvenn

2 ~ 6 sets venn diagram for python
The Unlicense
311 stars 119 forks source link

Can't get past the first line of the tutorial. TypeError: descriptor 'union' requires a 'set' object but received a 'range' #12

Closed soliverc closed 4 years ago

soliverc commented 4 years ago

I'm trying the first line of the tutorial but get a typerror. See below:

import venn
import matplotlib
matplotlib.use('Agg')

labels = venn.get_labels([range(10),range(5, 15)], fill=['number', 'logic'])

TypeError                                 Traceback (most recent call last)
<ipython-input-151-0893ce4030bb> in <module>
      4 
      5 
----> 6 labels = venn.get_labels([range(10),range(5, 15)], fill=['number', 'logic'])

~\Anaconda3\lib\site-packages\venn\_backwards_compatibility.py in get_labels(data, fill)
     24     if "percent" in fill:
     25         fmt += "({percentage:.1f}%)"
---> 26     return generate_petal_labels(data, fmt)
     27 
     28 def vennx(labels, names, colors=OLD_COLORS, figsize=(9, 9), dpi=None, fontsize=14):

~\Anaconda3\lib\site-packages\venn\_venn.py in generate_petal_labels(datasets, fmt)
     58     datasets = list(datasets)
     59     n_sets = len(datasets)
---> 60     dataset_union = set.union(*datasets)
     61     universe_size = len(dataset_union)
     62     petal_labels = {}

TypeError: descriptor 'union' requires a 'set' object but received a 'range'
soliverc commented 4 years ago

Ok, solved by wrapping set() around the range.

labels = venn.get_labels([set(range(10)),set(range(5, 15))], fill=['number', 'logic'])

All parts of the tutorial fail due to this error.

tctianchi commented 4 years ago

Sorry, the question you asked is definitely not from the code in this project. You are using a fork. Please check the corresponding repository.