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

Fixes to support Python2 and Python3 simultaneously #33

Merged
merged 45 commits into from
Feb 14, 2016

Conversation

rdeits
Copy link
Contributor

@rdeits rdeits commented Jan 20, 2016

This pull request makes the following changes:

  • merges in origin/master to synchronize the python2 and python3 codebases
  • adds appropriate from future imports to get around syntax differences in python2 and python3
  • fixes some minor version-specific issues (such as the fact that strings have iter in python3 but not python2, and that None is not comparable in python3)
  • adds integer floor division where necessary

I've verified that all unit tests pass on this branch in both python2.7 and python3.5, with the exception of one test (which also fails on master in python2.7):

Error the solver does not support this expression: (x in {0..10} + x in {0..10} + 0.5)
Type: <class 'Numberjack.Sum'>
Children: [<Numberjack.Variable object at 0x10e2e4f10>, <Numberjack.Variable object at 0x10e2e4590>] [<class 'Numberjack.Variable'>, <class 'Numberjack.Variable'>]
Params: [[1, 1], 0.5]
E..........................................................................................................
======================================================================
ERROR: testSuccess11 (tests.LinearTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/rdeits/Projects/Numberjack/tests/LinearTest.py", line 159, in testSuccess11
    solver = LinearTest.solver(te.model)
  File "Numberjack/solvers/Mistral.py", line 977, in __init__
    Numberjack.NBJ_STD_Solver.__init__(self, "Mistral", "Mistral", model, X, FD, clause_limit, encoding)
  File "Numberjack/__init__.py", line 3138, in __init__
    self.solver.add(self.load_expr(expr))
  File "Numberjack/__init__.py", line 3249, in load_expr
    arguments = [self.load_expr(child) for child in expr.get_children()]
  File "Numberjack/__init__.py", line 3284, in load_expr
    raise e
NotImplementedError: Wrong number or type of arguments for overloaded function 'new_Mistral_Sum'.
  Possible C/C++ prototypes are:
    Mistral_Sum::Mistral_Sum(MistralExpArray &,MistralIntArray &,int const)
    Mistral_Sum::Mistral_Sum(MistralExpArray &,MistralIntArray &)
    Mistral_Sum::Mistral_Sum(Mistral_Expression *,Mistral_Expression *,MistralIntArray &,int const)
    Mistral_Sum::Mistral_Sum(Mistral_Expression *,MistralIntArray &,int const)
    Mistral_Sum::Mistral_Sum()

I've also verified that all of the examples in the examples/ folder run without error in python2 and python3, although I haven't actually verified their outputs against the problem descriptions.

I hope you find this useful 😄

ehebrard and others added 30 commits May 8, 2015 14:05
Need to have this test all solvers, not just manually specifying one.
But there is still a big problem with the scip variables and constraints not being released. Could not figure it out without causing seg faults.
@rdeits rdeits mentioned this pull request Jan 20, 2016
9thbit added a commit that referenced this pull request Feb 14, 2016
Fixes to support Python2 and Python3 simultaneously
@9thbit 9thbit merged commit 5eb1cd4 into eomahony:Python3 Feb 14, 2016
@9thbit
Copy link
Collaborator

9thbit commented Feb 14, 2016

This is excellent, thank you @rdeits! 👍 Apologies for the delay, had a busy few weeks. :)

@rdeits
Copy link
Contributor Author

rdeits commented Feb 14, 2016

Happy to help :)

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.

4 participants