Skip to content

Python 3 compatibility #272

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

Merged
merged 34 commits into from
Nov 20, 2016
Merged

Python 3 compatibility #272

merged 34 commits into from
Nov 20, 2016

Conversation

maxpumperla
Copy link
Contributor

This pull request addresses the topics:

  • Full python 2 and 3 compatibility (no 2to3 needed), all tests green for 2.7-3.5.
  • Added six as new dependency to ensure backward compatibility
  • PEP8 linting for project
  • preparing a new release 0.1 to support python 3

@maxpumperla
Copy link
Contributor Author

@jaberg I'd like to merge this as soon as possible, so that we can get out a new release soon. A lot of people seem to be waiting for this.

If there's anything you don't like or would like to see improved, please let me know.

Copy link
Contributor

@jaberg jaberg left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! These changes look great. I made some notes of minor cleanup as I went, but I'd consider most of these nice-to-haves rather than blockers. The only things I'd request to look at are a couple of print statements that I flagged as not printing to stderr properly, and the removal of the defaults variable in the function inspection code.

@@ -148,7 +147,7 @@ def set_in_memo(self, memo, k, v):
# then we can free memo[ii] by replacing it
# with a dummy symbol
if all(iic in memo for iic in self.clients[ii]):
#print 'collecting', ii
# print('collecting', ii)
Copy link
Contributor

Choose a reason for hiding this comment

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

del

#ltvs = np.asarray(sorted(zip(losses, tids, vals)))
#best_loss, best_tid, best_val = ltvs[best_idx]
# ltvs = np.asarray(sorted(zip(losses, tids, vals)))
# best_loss, best_tid, best_val = ltvs[best_idx]
Copy link
Contributor

Choose a reason for hiding this comment

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

del

@@ -309,14 +315,14 @@ def __iter__(self):
try:
return iter(self._trials)
except AttributeError:
print(sys.stderr, "You have to refresh before you iterate")
print((sys.stderr, "You have to refresh before you iterate"))
Copy link
Contributor

Choose a reason for hiding this comment

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

(1) how to print to a specific fd in py3?
(2) does insisting on stderr make sense here?

raise

def __len__(self):
try:
return len(self._trials)
except AttributeError:
print(sys.stderr, "You have to refresh before you compute len")
print((sys.stderr, "You have to refresh before you compute len"))
Copy link
Contributor

Choose a reason for hiding this comment

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

stder business again here

# print pmin
# print loss3[:cutoff, 0]
# print loss3[:cutoff, 1]
# print loss3[:cutoff, 2]
Copy link
Contributor

Choose a reason for hiding this comment

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

del

b_post = fn(*b_args, **dict(named_args))
a_args = [obs_above, prior_weight] + aa
a_post = fn(*a_args, **dict(named_args))

assert a_post.name == b_post.name
fn_lpdf = getattr(scope, a_post.name + '_lpdf')
#print fn_lpdf
# print fn_lpdf
Copy link
Contributor

Choose a reason for hiding this comment

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

del

#print 'FULL IDXS'
#print full_idxs
# print 'FULL IDXS'
# print full_idxs
Copy link
Contributor

Choose a reason for hiding this comment

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

del

@@ -742,14 +752,14 @@ def idxs_prod(full_idxs, idxs_by_label, llik_by_label):
assert len(idxs) == len(llik)
for ii, ll in zip(idxs, llik):
rval[pos_of_tid[ii]] += ll
#rval[full_idxs.index(ii)] += ll
# rval[full_idxs.index(ii)] += ll
Copy link
Contributor

Choose a reason for hiding this comment

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

del

return rval


@scope.define
def broadcast_best(samples, below_llik, above_llik):
if len(samples):
#print 'AA2', dict(zip(samples, below_llik - above_llik))
# print 'AA2', dict(zip(samples, below_llik - above_llik))
Copy link
Contributor

Choose a reason for hiding this comment

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

del

from .pyll import toposort
from .pyll import scope
from .pyll import stochastic
# from pyll import clone_merge
Copy link
Contributor

Choose a reason for hiding this comment

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

del

@maxpumperla
Copy link
Contributor Author

Alright @jaberg, that should do it for now. I'll address CI and other enhancements later on. I'll do a last few test and would then proceed to merge this. Thanks again for having me onboard!

@maxpumperla maxpumperla merged commit f38b538 into master Nov 20, 2016
@maxpumperla
Copy link
Contributor Author

@jaberg I pushed the new tag 0.1, but pypi requires a password when running

python setup.py sdist upload -r pypi

would you do the honors and quickly do this? Thanks!

@jaberg
Copy link
Contributor

jaberg commented Nov 21, 2016

Tomorrow morning I'll take the new code for a spin on py27 and upload it if
the unit tests pass.

On Sun, Nov 20, 2016 at 3:59 AM, Max Pumperla notifications@github.com
wrote:

@jaberg https://github.com/jaberg I pushed the new tag 0.1, but pypi
requires a password when running

python setup.py sdist upload -r pypi

would you do the honors and quickly do this? Thanks!


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#272 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAKdDIsUu-aTW0-8BRor3DAqkJ5eTsCqks5rADYigaJpZM4K3VGm
.

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