OpenSMFS / FRETBursts

Burst analysis software for single and multi-spot single-molecule FRET (smFRET) data.
https://opensmfs.github.io/FRETBursts/
GNU General Public License v2.0
12 stars 9 forks source link

Deprecation warning for Matplotlib 3.0.2 #23

Closed mayeshh closed 5 years ago

mayeshh commented 5 years ago

I am getting a persistent deprecation warning for many of the dplot() functions.

This is the error:

/Users/maya/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_base.py:3610: MatplotlibDeprecationWarning: Theymaxargument was deprecated in Matplotlib 3.0 and will be removed in 3.2. Usetopinstead. alternative='top', obj_type='argument') /Users/maya/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_base.py:3604: MatplotlibDeprecationWarning: Theyminargument was deprecated in Matplotlib 3.0 and will be removed in 3.2. Usebottominstead. alternative='bottom', obj_type='argument')

Repeated many times.

I have gone into my copy of burst_plot.py and changed all instances of ymax to top and ymin to bottom. I saved the file and relaunched the notebook, but the warning persists.

tritemio commented 5 years ago

Thanks for opening the issue.

Feel free to submit a PR to fix the issue :). Steps:

  1. fork FRETBursts and clone your for fork in your laptop/pc
  2. make a branch and switch to it: git checkout -b fix_warning
  3. install FRETBursts from the source folder: activate the environment of your choice, then pip install -e . twice from the source folder
  4. do the modifications and commit
  5. test that the fix works. If not, amend the modifications
  6. push the modifications to github, they will go to your forked copy
  7. from your fork on github open a pull request (PR).

Let me know if you have any problems following the above steps.

tritemio commented 5 years ago

Fixed on master by d43bf6e1051d7eab15a79835780d559e40f58b43

mayeshh commented 5 years ago

I'm sorry I was unable to help with this. I replaced all instances of ymin and ymax to top and bottom, but the warning persisted. I don't understand this because I am running Matplotlib 3.0.3 and FRETBursts.

Since I didn't fix the warning myself, I pulled your fix using git pull origin master. But, the depreciation warning still persists on my system... Am I missing something important? This makes me think that something is wrong with my system. Do you have any advice? I have also tried removing and installing the development version FRETBursts multiple times, but that didn't help either.

tritemio commented 5 years ago

The fix in the code is the same you did. For some reason, you are not using the fixed version. You must have another installed version that overrides the fixed one. To see where a package you import is on disk fretbursts.__file__.

I'll try to whole process for you, let's see. I recall I have fretbursts installed in an env called py37-sm:

(base) Antonios-MacBook-Pro:~ anto$ conda activate py37-sm
(py37-sm) Antonios-MacBook-Pro:~ anto$ ipython
Python 3.7.2 (default, Dec 29 2018, 00:00:04) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.3.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import fretbursts                                                                                                                      
 - Optimized (cython) burst search loaded.
 - Optimized (cython) photon counting loaded.
--------------------------------------------------------------
 You are running FRETBursts (version 0.7).

 If you use this software please cite the following paper:

   FRETBursts: An Open Source Toolkit for Analysis of Freely-Diffusing Single-Molecule FRET
   Ingargiola et al. (2016). http://dx.doi.org/10.1371/journal.pone.0160716 

--------------------------------------------------------------

In [2]: fretbursts.__version__                                                                                                                 
Out[2]: '0.7'

In [3]: fretbursts.__file__                                                                                                                    
Out[3]: '/Users/anto/miniconda3/envs/py37-sm/lib/python3.7/site-packages/fretbursts/__init__.py'

alright. So here I have fretbursts 0.7 installed in /Users/anto/miniconda3/envs/py37-sm/. Now I remove it and install the latest version from github:

conda remove fretbursts
pip uninstall fretbursts   # just to be sure in case it was not installed by conda
cd ~/src/fretbursts        # go to the git repo
git pull                   # pull the latest version
conda install cython       # make sure cython is installed
python setup.py build      # this should print a version like '0.7+25.g0317ec9'

At this point I get this error:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command 'gcc' failed with exit status 1

I recently upgraded to Mojave, google found me this fix. So I try it:

xcode-select --install

Then I try again python setup.py build, this time I get another error:

fretbursts/phtools/burstsearch_c.c:20208:21: error: no member named 'exc_type' in 'struct _ts'
    *type = tstate->exc_type;
            ~~~~~~  ^
fretbursts/phtools/burstsearch_c.c:20209:22: error: no member named 'exc_value' in 'struct _ts'; did you mean 'curexc_value'?
    *value = tstate->exc_value;
                     ^~~~~~~~~
                     curexc_value
/Users/anto/miniconda3/envs/py37-sm/include/python3.7m/pystate.h:240:15: note: 'curexc_value' declared here
    PyObject *curexc_value;
              ^
fretbursts/phtools/burstsearch_c.c:20210:19: error: no member named 'exc_traceback' in 'struct _ts'; did you mean 'curexc_traceback'?
    *tb = tstate->exc_traceback;
                  ^~~~~~~~~~~~~
                  curexc_traceback

...

/Users/anto/miniconda3/envs/py37-sm/include/python3.7m/pystate.h:241:15: note: 'curexc_traceback' declared here
    PyObject *curexc_traceback;
              ^
fretbursts/phtools/burstsearch_c.c:20307:13: error: no member named 'exc_type' in 'struct _ts'
    tstate->exc_type = *type;
    ~~~~~~  ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
error: command 'gcc' failed with exit status 1

Again, google brought me here and to a linked issue here. Magic word "Recythonizing" should fix it. It means regenerating the *.c files (because last time they where created I was on python <3.7):

rm fretbursts/phtools/*.c
python setup.py build

This time no error (only some warning but these are benign). For reference, the last output line of the previous command is:

gcc -bundle -undefined dynamic_lookup -L/Users/anto/miniconda3/envs/py37-sm/lib -arch x86_64 -L/Users/anto/miniconda3/envs/py37-sm/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.7-x86_64-3.7/fretbursts/phtools/phrates_cy.o -o build/lib.macosx-10.7-x86_64-3.7/phrates_c.cpython-37m-darwin.so

Now that the fretbursts extensions are built, we can install it in dev (or editable) mode:

pip install -e .

(do it twice just in case ;-) )

Let's try to import fretbursts, to avoid any issue I first move to another folder:

(py37-sm) Antonios-MacBook-Pro:fretbursts anto$ cd
(py37-sm) Antonios-MacBook-Pro:~ anto$ ipython
Python 3.7.2 (default, Dec 29 2018, 00:00:04) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.3.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import fretbursts                                                                                                                      
 - Optimized (cython) burst search loaded.
 - Optimized (cython) photon counting loaded.
--------------------------------------------------------------
 You are running FRETBursts (version 0.7+25.g0317ec9).

 If you use this software please cite the following paper:

   FRETBursts: An Open Source Toolkit for Analysis of Freely-Diffusing Single-Molecule FRET
   Ingargiola et al. (2016). http://dx.doi.org/10.1371/journal.pone.0160716 

--------------------------------------------------------------

In [2]: fretbursts.__version__                                                                                                                 
Out[2]: '0.7+25.g0317ec9'

In [3]: fretbursts.__file__                                                                                                                    
Out[3]: '/Users/anto/src/FRETBursts/fretbursts/__init__.py'

In [4]:  

Works! Note that the path is in now '/Users/anto/src/FRETBursts/. Hope this helps.

PS: On the hindsight, it was much more complicated than expected, sorry about that. At least for me, the issue were due to the Mojave update plus switching to python 3.7 at the same time.

mayeshh commented 5 years ago

I think I finally fixed it, but not using this method. I did try to follow your instructions step by step, but I kept getting errors. Finally, google helped me to find the solution, which is to change /usr/local/include to /usr/local/indlude_old. The name doesn't matter but I was afraid to delete the file, and this change has fixed the issue!!!!!

EDIT: I tried to run my notebooks using the new FRETBursts, and had errors. So I decided to try removing my py37 environment and set up a new one called py37-fb based on your installation instructions. Doing this allowed me to run the notebook without errors, but I noticed that this reverted my version of FRETBursts back to 0.7. Also, the deprecation warning is still there :'(

At least pip install -e . and cython are working...

tritemio commented 5 years ago

Ok, at least now it is just a conda environment issue. Mind that ~/src/fretbursts/ is simply the folder where I downloaded fretbursts source code by doing git clone, your folder may be different.

Now that you solved the issue compiling the code, try creating a new env and install fretburst in it. To test, open ipython from the terminal and do import frebursts.

conda create -n py37-fb python=3.7 fretbursts cython  # this installs the dependencies
conda activate py37-fb
conda uninstall fretbursts
cd ~/src/fretbursts
python setup.py build
pip install -e .
cd ~
ipython
In [1]:  import fretbursts

This should give you the new latest frebursts installed from sources (version '0.7+25.g0317ec9' or later). If it works, create a kernel for the notebook:

python -m ipykernel install --user --name py37-fb --display-name "Python 3.7 (FB)"

After that, from a new terminal, launch jupyter notebook (base environment) and select the kernel "Python 3.7 (FB)".

mayeshh commented 5 years ago

Thank you so much for helping me get through all of this. I was very confused, and I learned a lot through the whole procedure.

I'm sorry to keep this thread going, but there is yet another depreciation warning, (originating from dplot(d, timetrace_bg)) but this time it comes from matplotlib rather than FRETBursts:

/Users/maya/anaconda3/envs/py37-fb/lib/python3.7/site-packages/matplotlib/axes/_base.py:3604: MatplotlibDeprecationWarning: The ymin argument was deprecated in Matplotlib 3.0 and will be removed in 3.2. Use bottom instead. alternative='bottom', obj_type='argument')

I do not understand this because matplotlib is up-to-date. I confirmed this for myself running ipython:

In [2]: import matplotlib
In [3]: matplotlib.__version__
Out[3]: '3.0.3'

Are these .py files not part of the matplotlib module?

tritemio commented 5 years ago

My bad, I forgot to rename ymin -> bottom in other 2 places. Thanks for reporting it.