question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inheritance of Purity

See original GitHub issue

(As discussed here: http://stackoverflow.com/questions/42773134/inheritance-of-purity/42773643)

I have a question about inheritance of function purity. For example, consider this case:

In [1]: from dask import delayed

In [2]: myArr = delayed(np.ones, pure=True)((10,10))

In [3]: myArr
Out[3]: Delayed('ones-850ff41a84b309775d01d5f3e5c4d1c4')

In [4]: myArr = delayed(np.ones, pure=True)((10,10))

In [5]: myArr
Out[5]: Delayed('ones-850ff41a84b309775d01d5f3e5c4d1c4')

In [6]: myArr.shape
Out[6]: Delayed('getattr-de14f312-2605-4fc4-a419-c376520f73b4')

In [7]: myArr.shape
Out[7]: Delayed('getattr-9e547a62-0bc6-43e5-8d3c-cac532b73511')

In [8]: delayed(getattr, pure=True)(myArr, 'shape')
Out[8]: Delayed('getattr-5224be928bad33c9778d4f96d610cc37')

In [9]: delayed(getattr, pure=True)(myArr, 'shape')
Out[9]: Delayed('getattr-5224be928bad33c9778d4f96d610cc37')

I would expect line [6] and [7] to yield the same key, since they are accessing an attribute from a delayed instance declared pure. However, it is not the case, and I must explicitly declare the getattr method to be pure for this to work, as seen in lines [8] and [9].

As discussed in the stackoverflow link, this seems to be purely an issue of dask semantics. I would be inclined to voting for purity to be inherited. But I am a new user, so I would appreciate feedback/comments on this. Thanks!

PS: The eventual use case is for dask distributed. It seems that the way purity is treated in this case may possibly be different than the case listed here.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
jcristcommented, Mar 14, 2017

I applied my proposal above in #2084. I think this is internally consistent, so this approach would be my vote.

0reactions
jrmlhermittecommented, Mar 14, 2017

Thanks, I vote for this as well 😃. I like the elaborated documentation, very useful as well!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Law of Purity of Gametes - Biology Online
(genetics) Gregor Mendel's law stating that the unit factors are brought together and paired during union or fertilization; however, these unit ...
Read more >
Mendelian Inheritance and the Purity of the Gametes - Science
Mendelian Inheritance and the Purity of the Gametes. E. B. WilsonAuthors Info & Affiliations. Science. 19 Jan 1906. Vol 23, Issue 577. pp....
Read more >
MENDELIAN INHERITANCE AND THE PURITY OF THE GAMETES
MENDELIAN INHERITANCE AND THE PURITY OF THE GAMETES. Science. 1906 Jan 19;23(577):112-3. doi: 10.1126/science.23.577.112-a.
Read more >
Law of Segregation-Law of Purity of Gametes (Genetics)
Biology by Dr. N.S. Jain ||○SUBSCRIBE NOW FOR MORE VIDEOS○In this video I have explained the topic in descriptive way so that you...
Read more >
What is reason of purity of gametes? - Toppr
Dominance · Segregation · Independent assortment · Blending · According to Mendel's second law of inheritance or the law of segregation, members of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found