Seite 1 von 1

PyDoc will nicht so recht ...

Verfasst: Dienstag 20. September 2005, 08:23
von CM
Hoi

Sagt mal, woran kann es liegen, daß
$ pydoc Data.py
nur "no Python documentation found for 'Data.py'" ergibt, während im interaktiven Modus mit "help(Data)" ganz wunderbar alles herauskommt, was man auch mit PyDoc erwartet? Ich sollte erwähnen, daß ich u. a. scipy importiere, ansonsten aber nur sehr gut dokumentierte Standardmodule.

Oder gibt es irgendwo eine Dokumentation von PyDoc? Alles was ich bisher gefunden habe ist: "Schreibt fleissig Docstrings" und es wird funktionieren. Schön, tut es aber nicht - hier liegt in meinen Augen mal eine deutliche Schwäche der Pythondokumentation ...

Tut mir leid, daß ich nicht mehr Info bieten kann, um das Problem zu lösen, aber vielleicht weiß ja jemand von euch trotzdem spontan Rat.

Vielen Dank vorab,
Christian

PS Der Kopf des in Frage stehenden Moduls sind folgendermaßen aus:

Code: Alles auswählen

"""SPlot & CLI source modules

<snip>

Version History:

0.0     first basic modul containing the following functions:
        fromFile, toFile, fromASA, toASA, attributes, swap_axes, scale, normalize, inv, norminv,
        log_intensity, log_energy, substractBuffer, _maximum, _maxwhere, fit_gaussian, __residuals,
        __peval
0.1     added the following functions:
        merge_datasets (outside SAXSraw), _recalculate_error
        
        altered the following functions:
        normalize (now new error estimates gets calculated)
"""
#import futures division: prevent floating point and integer division confusion
from __future__ import division

#import auxillary modules
from scipy import *
from scipy.optimize import leastsq
import sys, pickle
import re
#from Utils import MovingSlitLookUp

__author__ = "Christian Meesters"
__version__ = "0.1"

#define exceptions
class SAXSError(Exception):
    """Exception helper class for defining and tuning Exceptions
    - for internal use, only"""
    def __init__(self,value):
        self.value = value
    def __str__(self):
        return repr(self.value)
class SAXSInputError(SAXSError): pass
class SAXSIOError(SAXSError): pass
class SAXSRangeError(SAXSError): pass
class SAXSKeyError(SAXSError): pass
class SAXSTypeError(SAXSError): pass
class SAXSAttributeError(SAXSError): pass

_attributes = {'name':None, 'date':None, 'operator': 'me','instrument':None,\
'xlabel':'channels', 'ylabel':'Intensity [counts]', \
'energy_channels':None,'position_channels':None,'lower_limit':None,\
'upper_limit':None,'stop_condition':None,'stopped_by_user':False,\
'realtime':None,'lifetime':None,'energy_counts':None,'position_counts':None,\
'concentration':None,'wavelength':None,'origin':None,'comment':'', 'out':sys.stdout}

_supported_formats_ = ['ASA','SPL']
#ASA is belonging to the ASA software
#SPL is the own format

class SAXSraw:
    """
        class containing raw SAXS data and some initialization methods
    """
    def __init__(self, intensity=None, ichannel=None, energy = None, echannel = None, intensity_error = None, q = None, **kwargs):
        """
                Creates SAXSraw instance
            
            Possible input parameters are:
            - a list of intensity data (defaults to None)
                     - the corresponding list of channel data (defaults to None)
                     - a list of the response ('energy') spectrum (defaults to None)
                     - the corresponding list of channel data (defaults to None)
            - meta data (all default to None)
            - outstream buffer (defaults to sys.stdout)
            
            invoke like: x = SAXSraw(intensity data, intensity channels,[name,[meta,[out]]])
            e.g. x = SAXSraw([a list of intensity data],[a second list of corresponding channels],\
            name="some name", date="some date")
            
            Creates SAXSraw instance
            
            Possible input parameters are:
            - a list of numerical data
            - a range descriptor (tuple, defaults to (None,None))
            - a name (defaults to None)
            - meta data (defaults to None)
            - a 'date' of the experiment
            - outstream buffer (defaults to sys.stdout)
            
            invoke like: x = SAXSraw(intensity data, intensity channels,[name,[meta,[out]]])
            e.g. x = SAXSraw([a list of intensity data],[a second list of corresponding channels],\
            name="some name", date="some date")
        """

Verfasst: Dienstag 20. September 2005, 09:41
von mawe
Hi!

Ich nehme mal an, dass Du pydoc von dem Verzeichnis aus aufrufst, in dem auch Data.py ist, oder? Dann versuch mal

Code: Alles auswählen

pydoc ./Data.py
Bei mir funktioniert es dann. Anscheinend sucht pydoc nicht im aktuellen Verzeichnis (keine Ahnung wie man das einstellt).

Gruß, mawe

Verfasst: Dienstag 20. September 2005, 09:50
von henning
Oder gib den Modulnamen statt dem Dateinamen an, also:

Code: Alles auswählen

pydoc Data

Verfasst: Dienstag 20. September 2005, 09:52
von mawe
Das is natürlich noch besser :)

Verfasst: Dienstag 20. September 2005, 10:45
von CM
Jau, funktioniert bestens :oops: :oops:

Vielen Dank,
Christian

Verfasst: Mittwoch 21. September 2005, 15:11
von CM
Tja, da hätte ich wohl die (reichlich kurze) Doku wohl besser lesen sollen. Dennoch habe ich da ein Problem, mit dem ich nicht weiterkomme:

Wenn ich pydoc mit dem -w flag starte, funktioniert es nämlich bei meinem Data-Modul nicht mehr. Bei allen anderen Modulen macht es ganz wunderschöne html-Files.
Hier ist ein Auszug aus dem ewiglangen Traceback:

Code: Alles auswählen

raceback (most recent call last):
  File "/usr/bin/pydoc", line 4, in ?
    pydoc.cli()
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/pydoc.py", line 2117, in cli
    writedoc(arg)
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/pydoc.py", line 1383, in writedoc
    page = html.page(describe(object), html.document(object, name))
  File "/Users/maxwell/Packages/SciPy_complete-0.3.2/build/lib.darwin-7.7.0-Power_Macintosh-2.3/scipy_base/ppimport.py", line 397, in _scipy_pydoc_Doc_document
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/pydoc.py", line 283, in document
    if inspect.ismodule(object): return self.docmodule(*args)
<snip>
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/repr.py", line 49, in repr_list
    s = s + self.repr1(x[i], level-1)
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/pydoc.py", line 319, in repr1
    return self.escape(cram(stripid(repr(x)), self.maxother))
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/pydoc.py", line 111, in stripid
    if re.search(pattern, repr(Exception)):
  File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/sre.py", line 137, in search
    return _compile(pattern, flags).search(string)
RuntimeError: maximum recursion depth exceeded
Das Programm ist sicher über drei Stunden gelaufen (und dann habe ich es natürlich mehrmals probiert, weshalb ich auch jetzt erst wieder schreibe). Ein Bug in Pydoc vielleicht? Oder hat jemand eine Idee, woran es sonst liegen könnte?

Gruß,
Christian

Verfasst: Montag 26. September 2005, 08:14
von CM
Ein Nachtrag fürs Protokoll:

die Lösung hat mir der Paul Brian über die Tutor Mailing Liste gesteckt. Ganz einfach: Alle Imports mit "import scipy" und "from scipy import irgendwas" auskommentieren. Da hätte ich auch selber drauf kommen können. Das Problem scheint zu sein, daß sowie es rekursive Importe in irgendwelchen Submodulen gibt PyDoc auf die Schnauze fliegt, weil ewig weit versucht wird die Dokumentation ein zu lesen. Ein klarer Bug - ich versuche mal herauszufinden, ob er irgendwo schon dokumentiert ist. Wenn jemand von euch näheres weiß, bitte mir Bescheid geben.

Gruß,
Christian