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

Feature/map output #160

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

erik-whiting
Copy link
Contributor

@erik-whiting erik-whiting commented Jul 2, 2022

This is in support of issue #143, let me know if this is what you're looking for. Thanks!

PS, there are some refactors in this PR

@timosachsenberg
Copy link
Contributor

looks good from my side. Maybe wait for Julianus to give some feedback.
Also to decide if we should already bump up the autowrap version.

Copy link
Contributor

@jpfeuffer jpfeuffer left a comment

Choose a reason for hiding this comment

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

Yes looks good. Also the small refactor is nice.
But did you think about a bigger refactor in a way that there is one big code template for the while loop and the access and conversion of keys and values is just substitutable?

Then you just have very small if-cases in the beginning that setup these variables and way less duplication and complexity.

|cdef libcpp_map[$cy_tt_key, $cy_tt_value].iterator $it = $input_cpp_var.begin()
|cdef $py_tt_key $item_key
|while $it != $input_cpp_var.end():
| #$output_py_var[$key_conv] = $value_conv
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove?

| #$output_py_var[$key_conv] = $value_conv
| $item_key = $py_tt_key.__new__($py_tt_key)
| $item_key.inst = shared_ptr[$cy_tt_key](new $cy_tt_key((deref($it)).first))
| # $output_py_var[$key_conv] = $value_conv
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove?

):
value_conv = "<%s>(deref(%s).second)" % (cy_tt_value, it)
key_conv = "deref(<%s *> (<%s> key).inst.get())" % (cy_tt_key, py_tt_key)
cy_tt = tt_value.base_type
Copy link
Contributor

Choose a reason for hiding this comment

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

cy_tt_value_base? Feel free to use better variable names. You do not need to stay with the old ones.

@erik-whiting
Copy link
Contributor Author

@jpfeuffer it's ready for another look whenever you have time

@erik-whiting erik-whiting force-pushed the feature/map-output branch 2 times, most recently from cabf5b6 to 786db2a Compare July 17, 2022 19:27
@erik-whiting
Copy link
Contributor Author

Hey @jpfeuffer, I implemented the approach you suggested for building the cython code for output_provider. This approach reduced a lot of redundancy. As a result, the method is significantly shorter.

Let me know if you want me to change anything. If you merge this, I think I'll use it as the base for future refactoring in that same file, should make it a lot smaller and easier to understand. Lmk!

@jpfeuffer
Copy link
Contributor

Yes, a bit better. Still not quite completely refactored IMO:
Bildschirmfoto 2022-07-25 um 15 34 20

This applies to other if-cases and maybe more variables in the template code.

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.

3 participants