Giter VIP home page Giter VIP logo

Comments (6)

ElEd2 avatar ElEd2 commented on July 19, 2024

Hi,

Actually, my mistake the methods do work, what doesn't work is ipython's autocomplete, which only shows the non-auto-generated functions.

Ed

from pyvips.

jcupitt avatar jcupitt commented on July 19, 2024

Hello, the autogenerated method docs are generated for sphinx by this:

https://github.com/jcupitt/pyvips/blob/master/pyvips/voperation.py#L453

pyvips tries to help things like ipython autocomplete by adding help messages for the autogen methods. For example:

$ python
Python 2.7.14 (default, Sep 23 2017, 22:06:14) 
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvips
>>> help(pyvips.Image.black)
Help on function call_function in module pyvips.vimage:

call_function(*args, **kwargs)
    Make a black image.
    
    Example:
       out = pyvips.Image.black(width, height, bands = int)
    
    Returns:
        out (Image): Output image
    
    Args:
        width (int): Image width in pixels
        height (int): Image height in pixels
    
    Keyword args:
        bands (int): Number of bands in image
    
    Raises:
        :class:`.Error`
>>>

which is made by this:

https://github.com/jcupitt/pyvips/blob/master/pyvips/voperation.py#L252

It works for members too, for example:

>>> x = pyvips.Image.new_from_file("/data/john/pics/k2.jpg")
>>> help(x.black)
... same as above

I don't know much about ipython. What would need to happen to fix the autocomplete?

from pyvips.

ElEd2 avatar ElEd2 commented on July 19, 2024

Hi,

Sorry, my knowledge is pretty limited with this kind of thing.

I see what you mean, indeed the help works. Though dir(pyvips.Image) doesn't show all the functions.

When I used "from gi.repository import Vips" I could find everything and when I looked at pyvips I couldn't. I assumed the library wasn't finding the .so correctly, so reinstalled in a couple of different ways. Probably worth highlighting this somehow to make sure it doesn't happen to others.

Ed

from pyvips.

jcupitt avatar jcupitt commented on July 19, 2024

There are two Python bindings. libvips comes with one based on pygobject, which has a range of annoying problems. That's the one you get with from gi.repository import Vips.

pyvips is a new one based on ffi which is much better. That's the one you install with pip.

Anyway, install with pip and just use import pyvips to get the new one.

from pyvips.

jcupitt avatar jcupitt commented on July 19, 2024

dir() will only show real methods. pyvips uses __getattr__ to detect the use of missing methods and look them up in libvips instead, so dir() won't work.

from pyvips.

ElEd2 avatar ElEd2 commented on July 19, 2024

Thanks, it all seems to work well.
Ed

from pyvips.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.