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

Added typecheck where self.__dict__ is used. #382

Merged
merged 4 commits into from
Sep 9, 2015
Merged

Added typecheck where self.__dict__ is used. #382

merged 4 commits into from
Sep 9, 2015

Conversation

choni
Copy link
Contributor

@choni choni commented Sep 3, 2015

It's about #381 .
To avoid error when self.dict contains something not function.

@okuta
Copy link
Member

okuta commented Sep 3, 2015

Thank you for your PR.

isinstance returns true in the case of subclass.
And, FunctionSet may contain FunctionSet.
Therefore, isinstance(func, (function.Function, function.FunctionSet)) is better.

Chainer project uses PEP8 and a part of OpenStack Style Guidelines related to general coding style.
http://docs.chainer.org/en/stable/contribution.html#coding-guidelines
Please fix coding style.

@okuta okuta added the cat:bug Bug report or fix. label Sep 3, 2015
@choni
Copy link
Contributor Author

choni commented Sep 3, 2015

OK. Fixed.

@choni
Copy link
Contributor Author

choni commented Sep 5, 2015

Fixed typecheck in _get_sorted_funcs.
Because, When _get_sorted_funcs is called dict not contains functions but tuples like below.

('conv1b', <chainer.functions.convolution_2d.Convolution2D object at 0x7fc5a47295d0>)

@okuta okuta self-assigned this Sep 7, 2015
@okuta
Copy link
Member

okuta commented Sep 7, 2015

I think to be good to use six.itervalues.

@choni
Copy link
Contributor Author

choni commented Sep 7, 2015

I overlooked iteritems is used in _get_sorted_funcs, instead of itervalues is used in to_gpu and to_cpu.
About _get_sorted_funcs, iteritems is used for sorted function.
So, I think dict.values() is not suitable.
And, I simplified if clause of _get_sorted_funcs.

@okuta
Copy link
Member

okuta commented Sep 9, 2015

OK. I misunderstood.

@okuta
Copy link
Member

okuta commented Sep 9, 2015

LGTM!
Thank you.

okuta added a commit that referenced this pull request Sep 9, 2015
Added typecheck where self.__dict__ is used.
@okuta okuta merged commit 5413653 into chainer:master Sep 9, 2015
@delta2323 delta2323 added this to the v1.3.1 milestone Sep 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat:bug Bug report or fix.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants