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

Move C++ code to Cython #87

Merged
merged 56 commits into from
Jun 24, 2017
Merged

Move C++ code to Cython #87

merged 56 commits into from
Jun 24, 2017

Conversation

fscottfoti
Copy link
Contributor

@fscottfoti fscottfoti commented Jun 24, 2017

This is a major rewrite of the layer between python and C++, which was previously written using the numpy C++ API, and now is written in cython. The C++ that remains has been cleaned up a bit and formatted.

The major functionality change is that global memory is no longer used, so reserve_num_graphs no longer needs to be called and Network objects can be created and destroyed at the user's pleasure.

untested

also dropped windows newlines
also all but one test is now passing
maybe even on travis
they are now defined as strings in c++ rather than having enums in c++ and strings in python which get redefined as ints.  this means they're only defined once and you can call get_available_aggregations and get_available_decays on the cython wrapper to get them from the C++ definitions
fscottfoti and others added 21 commits May 26, 2017 17:09
Changed a couple of data structures to support std::string as keys for
the containers of the POIs. It doesn't compile yet, there are some
issues with the Cython files.
Changed the `operator[]` to `insert()` calls because the map value type
doesn't have a default constructor.
Given the general style of the existing codebase, I migrated my use of
exceptions to presence test of elements in containers.

Still, it would be a good idea to define a behavior when the methods
are called with a non-existent element. The first step for that, it
would be to define a behavior for that in the python side.
In network.py, changing the call to send the string version of the
category instead of an integer. In the test, also changing the test
category to send a string instead of a number.
The `map::insert` call in `libch.cpp` was being called with an existing
network, with POIs defined. The behavior of the method in that case is
to do nothing, because the key is already defined. Now, the element is
checked for presence and in case it exists it is removed and then
replaced.

I removed the creation of an array of POI data structures from the
code. The initPOIs method is still present because it defines two
values (max_distance and max_items).

@fscottfoti We need to define if those values are actually useful, and
in that case if we should pass when creating the network, or at other
initialization step to avoid having to call this particular method.
Now the max_distance parameter (double) and the max_pois (integer) are
defined per category in the `initialize_category` call.
There are some issues with the handling in Python3 of the `bytes` and
`string` types. When that gets to the `cython` wrapper it generates and
error. Now, there are some more explicit conversions in the code, and
explicit literals when calling directly the functions on the tests.
By suggestion of @fscottfoti. Category parameter is now the first one,
leaving to the second and third place for maxitems and maxdistance.
added notes on reserve_num_graphs
Remove the need of POI initialization call
@coveralls
Copy link

coveralls commented Jun 24, 2017

Coverage Status

Coverage increased (+1.9%) to 90.891% when pulling ff80060 on cython into 3846333 on master.

@fscottfoti fscottfoti merged commit d543380 into master Jun 24, 2017
@fscottfoti fscottfoti deleted the cython branch June 24, 2017 05:09
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.

None yet

3 participants