diff options
Diffstat (limited to 'silx/sx/__init__.py')
-rw-r--r-- | silx/sx/__init__.py | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/silx/sx/__init__.py b/silx/sx/__init__.py index 87bfb9e..bdec6e6 100644 --- a/silx/sx/__init__.py +++ b/silx/sx/__init__.py @@ -1,7 +1,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2016-2017 European Synchrotron Radiation Facility +# Copyright (c) 2016-2018 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,31 +22,35 @@ # THE SOFTWARE. # # ###########################################################################*/ -"""Convenient module to use main features of silx from the console. - -Usage from (I)Python console or notebook: +"""This is a convenient package to use from Python or IPython interpreter. +It loads the main features of silx and provides high-level functions. >>> from silx import sx -With IPython/jupyter, this also runs %pylab. -From the console, it sets-up Qt in order to allow using GUI widgets. +When used in an interpreter is sets-up Qt and loads some silx widgets. +When used in a `jupyter <https://jupyter.org/>`_ / +`IPython <https://ipython.org/>`_ notebook, neither Qt nor silx widgets are loaded. + +When used in `IPython <https://ipython.org/>`_, it also runs ``%pylab``, +thus importing `numpy <http://www.numpy.org/>`_ and `matplotlib <https://matplotlib.org/>`_. """ + __authors__ = ["T. Vincent"] __license__ = "MIT" __date__ = "16/01/2017" -import logging +import logging as _logging import sys as _sys -_logger = logging.getLogger(__name__) +_logger = _logging.getLogger(__name__) # Init logging when used from the console if hasattr(_sys, 'ps1'): - logging.basicConfig() + _logging.basicConfig() # Probe ipython try: @@ -81,12 +85,22 @@ else: del _icons # clean-up namespace from silx.gui.plot import * # noqa - from ._plot import plot, imshow # noqa + from ._plot import plot, imshow, ginput # noqa + + try: + import OpenGL as _OpenGL + except ImportError: + _logger.warning( + 'Not loading silx.gui.plot3d features: PyOpenGL is not installed') + else: + del _OpenGL # clean-up namespace + from ._plot3d import contour3d, points3d # noqa # %pylab if _get_ipython is not None and _get_ipython() is not None: - _get_ipython().enable_pylab(gui='inline' if _IS_NOTEBOOK else 'qt') + _get_ipython().enable_pylab(gui='inline' if _IS_NOTEBOOK else 'qt', + import_all=False) # Clean-up @@ -96,7 +110,7 @@ del _IS_NOTEBOOK # Load some silx stuff in namespace -from silx import * # noqa +from silx import version # noqa from silx.io import open # noqa from silx.io import * # noqa from silx.math import Histogramnd, HistogramndLut # noqa |