Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update/python binding api #185

Merged
merged 9 commits into from
Jan 8, 2024

Conversation

xinyuli1204
Copy link
Contributor

@xinyuli1204 xinyuli1204 commented Jan 6, 2024

  1. port binding api in python
  2. support python api in macOS

@@ -33,6 +37,7 @@ class c_builder_compile_option_t(ctypes.Structure):
c_ion_buffer_t = ctypes.POINTER(ctypes.c_int)
c_ion_port_map_t = ctypes.POINTER(ctypes.c_int)

c_ion_port_bind_t = ctypes.POINTER(ctypes.c_int)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused?



# should use numpy type?
def bind_i8(self, v: int):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better design to provide a generic bind instead of type-specific method (e.g. bind_i8). The appropreate C-API can be determined by inspecting self.type and self.dim.

from ionpy import Node, Builder, Buffer, PortMap, Port, Param, Type, TypeCode
import numpy as np # TODO: rewrite with pure python

def test_binding():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test case for scalar parameter bind?

from ionpy import Node, Builder, Buffer, PortMap, Port, Param, Type, TypeCode
import numpy as np # TODO: rewrite with pure python

def test_binding():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you replicate the C++ testcase for port binding using Python API? I want to keep the same C++ and Python API semantics.

@xinyuli1204 xinyuli1204 marked this pull request as draft January 7, 2024 18:21
@xinyuli1204 xinyuli1204 marked this pull request as ready for review January 8, 2024 18:33
@iitaku iitaku self-requested a review January 8, 2024 23:44
@iitaku
Copy link
Collaborator

iitaku commented Jan 8, 2024

LGTM.

@iitaku iitaku merged commit 8374591 into fixstars:master Jan 8, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants