Skip to content

Conversation

@erickrf
Copy link

@erickrf erickrf commented Feb 6, 2019

I implemented the Python interface for grandparents, grandsiblings and change the signature for siblings, making it arguably less error-prone. Also improved the documentation of some Cython functions.

index_siblings_.assign(length, vector<int>(length+1, -1));
// If the arcs are to the left of a head token, they must be sorted by increasing
// modifier indices. If they are to the right, by decreasing indices.
void Initialize(const vector<Arc*> &arcs, const vector<Sibling*> &siblings) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we maybe use overloading to keep the old API valid too? To avoid breaking code that relies on this.

Same goes for the python wrapper.

Copy link
Author

Choose a reason for hiding this comment

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

Both functions kept for overloading

INT_DTYPE = np.int
FLOAT_DTYPE = np.float
ctypedef np.int_t INT_DTYPE_T
ctypedef np.float_t FLOAT_DTYPE_T
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is numpy used in this file for anything other than these typedefs? If not I think it is better to use the cython types rather than the numpy types here and avoid the import.

Copy link
Author

Choose a reason for hiding this comment

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

I got rid of the typedefs

setup.py Outdated
Extension("ad3.extensions",
["python/ad3/extensions.cpp"],
include_dirs=[".", "ad3"],
include_dirs=[".", "ad3", np.get_include()],
Copy link
Collaborator

Choose a reason for hiding this comment

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

same: if we can get away without a numpy build-time dependency it would be awesome; also revert the version number change please

Copy link
Author

Choose a reason for hiding this comment

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

This is not necessary anymore

del self.thisptr

def initialize(self, int length, list siblings, bool validate=True):
def initialize(self, list arcs, list siblings, bool validate=True):
Copy link
Collaborator

Choose a reason for hiding this comment

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

  • remove type annotation from arcs so the users can pass an int instead
if isinstance(arcs, int):
    arcs = [(i, j) for i in range... for j in range...]

# resume as usual

Copy link
Author

Choose a reason for hiding this comment

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

Using arcs_or_length and keeping it backwards compatibly

@erickrf
Copy link
Author

erickrf commented Apr 17, 2019

The last commit also adds more flexibility to the decode_matrix_tree function in the Python wrapper, also introduced in this PR.

@erickrf
Copy link
Author

erickrf commented Oct 9, 2019

Is this good to go now?

@vene
Copy link
Collaborator

vene commented Oct 9, 2019

hmm, I don't think decode_matrix_tree belongs in ad3, what is the case for adding it?

#define FACTOR_HEAD_AUTOMATON

#include "ad3/GenericFactor.h"
#include "FactorTree.h"
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this import needed? what for?

erickrf added 2 commits May 6, 2020 22:18
warning when installing with clang on macos
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