Giter VIP home page Giter VIP logo

Comments (3)

wojdyr avatar wojdyr commented on June 2, 2024

Python function returns Python object that wraps C++ object.
This is how the underlying C++ object is made accessible from Python.
If you have a C++ function that takes Grid as an argument, Python bindings to this function would take FloatGrid as an argument.

from gemmi.

ConorFWild avatar ConorFWild commented on June 2, 2024

So thats how I thought it worked, and indeed seems to do in most cases, but if I have a pybind function like:

m.def("test_grid",
		[](gemmi::Grid<float> grid)
		{
			return "Loading grid<float> worked";
		},
		"Test if grids load");

Then when ran in python with a FloatGrid

module.test_grid(grid)

Where grid is a gemmi.FloatGrid that comes from, say, mtz.transform_f_phi_to_map, it results in a type error:

TypeError: test_grid(): incompatible function arguments. The following argument types are supported:
    1. (arg0: gemmi::Grid<float>) -> str

Invoked with: <gemmi.FloatGrid(200, 240, 144)>

from gemmi.

wojdyr avatar wojdyr commented on June 2, 2024

Perhaps it's because these functions are in a different module than Grid? I didn't look into details, but I copied the test_grid function above to python bindings in gemmi, and calling gemmi.test_grid(grid) worked.

from gemmi.

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.