Skip to content

Conversation

great-way
Copy link
Contributor

@great-way great-way commented Mar 16, 2020

Stack from ghstack:

Differential Revision: D20498111

great-way added a commit that referenced this pull request Mar 16, 2020
ghstack-source-id: 008360c
Pull Request resolved: #34825
@great-way great-way requested a review from ezyang March 16, 2020 19:12
class TestOptim(TestCase):
def setUp(self):
super(TestOptim, self).setUp()
self.exact_dtype = True
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't do this; exact_dtype is intended to be a class global property. Just set exact_dtype = True directly in the class, like in the other PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure my understanding is correct. Doing self.exact_dtype = True in a class member function should be equivalent to directly set exact_dtype = True in the class? Also when we modify the inherited attribute exact_dtype, I guess it won't affect the attribute value of the parent's other subclasses, since they instantiate a different class object.

Copy link
Contributor

Choose a reason for hiding this comment

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

No it is not equivalent (although in this particular case I can believe that they are functionally equivalent)

ezyang-mbp:Dev ezyang$ python arf.py
True
Traceback (most recent call last):
  File "arf.py", line 9, in <module>
    print(A2.b)
AttributeError: class A2 has no attribute 'b'
ezyang-mbp:Dev ezyang$ cat arf.py
class A:
    b = True

class A2:
    def __init__(self):
        self.b = True

print(A.b)
print(A2.b)

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

looks promising!

@dr-ci
Copy link

dr-ci bot commented Mar 16, 2020

💊 CircleCI build failures summary and remediations

As of commit 85fee57 (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no CircleCI failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker.

This comment has been revised 17 times.

@great-way great-way changed the title Turn on exact_dtype by default on test_optim.py #34590 Turn on exact_dtype by default on test_optim.py Mar 16, 2020
great-way added a commit that referenced this pull request Mar 17, 2020
ghstack-source-id: 9afdeea
Pull Request resolved: #34825
@facebook-github-bot
Copy link
Contributor

@great-way merged this pull request in 5857a12.

@facebook-github-bot facebook-github-bot deleted the gh/great-way/1/head branch March 21, 2020 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants