Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Conversation

@szha
Copy link
Member

@szha szha commented Aug 30, 2017

this change includes:

  1. prevent attributes whose names don't start with '_' from changing types
  2. properly replace _children if both existing value and new value are blocks.

type2=type(value)))
if isinstance(existing, Block):
for i, c in enumerate(self._children):
if c == existing:
Copy link
Contributor

Choose a reason for hiding this comment

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

is instead of ==

@piiswrong
Copy link
Contributor

Please add tests for these new behaviors

# specific language governing permissions and limitations
# under the License.

import unittest
Copy link
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Contributor

Choose a reason for hiding this comment

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

use nosetest

if hasattr(self, name):
existing = getattr(self, name)
if not name.startswith('_') and not isinstance(value, type(existing)):
raise TypeError('Changing attribute type for {name} from {type1} to {type2}' \
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's restrict the check to Parameter and Block.

Copy link
Member Author

Choose a reason for hiding this comment

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

Existing attribute value can be NoneType and later changes to Block or Parameter. Should this be allowed?

@piiswrong piiswrong merged commit 7ca8b88 into apache:master Sep 2, 2017
@szha szha deleted the gluon_block_attr branch September 2, 2017 04:50
mbaijal pushed a commit to mbaijal/incubator-mxnet that referenced this pull request Sep 6, 2017
* forbid setattr type changes and enable block replacement

* update per comment

* add tests

* protect block and param
cjolivier01 pushed a commit to cjolivier01/mxnet that referenced this pull request Sep 11, 2017
* forbid setattr type changes and enable block replacement

* update per comment

* add tests

* protect block and param
crazy-cat pushed a commit to crazy-cat/incubator-mxnet that referenced this pull request Oct 26, 2017
* forbid setattr type changes and enable block replacement

* update per comment

* add tests

* protect block and param
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants