-
Notifications
You must be signed in to change notification settings - Fork 137
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
Asynchronous History Sampling #511
Changes from 1 commit
30fc6c2
a0a8e58
15911d1
e7fb0b6
54b083c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,7 +162,7 @@ def addRealization(self,rlz): | |
rlz = self._selectiveRealization(rlz) | ||
|
||
## check alignment of indexes | ||
self._checkAlignedIndexes(rlz) # TODO implement | ||
self._checkAlignedIndexes(rlz) | ||
# NB If no scalar entry is made, this construction fails. In that case, | ||
# instead of treating each dataarrray as an object, numpy.asarray calls their asarray methods, | ||
# unfolding them and making a full numpy array with more dimensions, instead of effectively | ||
|
@@ -689,11 +689,16 @@ def _checkAlignedIndexes(self,rlz,tol=1e-15): | |
for index in self.indexes: | ||
# if it's aligned so far, check if it still is | ||
if index in self._alignedIndexes.keys(): | ||
# if close enough, then keep the aligned values; otherwise, take action | ||
if isinstance(rlz[index][0],(float,int)): | ||
closeEnough = all(np.isclose(rlz[index],self._alignedIndexes[index],rtol=tol)) | ||
# first, if lengths don't match, they're not aligned. | ||
if len(rlz[index]) != len(self._alignedIndexes[index]): | ||
closeEnough = False | ||
else: | ||
closeEnough = all(rlz[index] == self._alignedIndexes[index]) | ||
# "close enough" if float/int, otherwise require exactness | ||
if isinstance(rlz[index][0],(float,int)): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about it is a numpy float or int? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. from my understanding, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do have an issue when the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a = np.array([6],dtype=np.integer)
type(a[0]) # result is <type 'numpy.int64'>
isinstance(a[0],int) # result is True
a = np.array([3.14],dtype=np.float)
type(a[0]) # result is <type 'numpy.float64'>
isinstance(a[0],float) # result is True Inheritance! 😃 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Paul.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are the fundamental data types from NumPy There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, do not add more here. This needs to be a seperate discussion from this PR. Let's focus. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is handled in #524. |
||
closeEnough = all(np.isclose(rlz[index],self._alignedIndexes[index],rtol=tol)) | ||
else: | ||
closeEnough = all(rlz[index] == self._alignedIndexes[index]) | ||
# if close enough, then keep the aligned values; otherwise, take action | ||
if not closeEnough: | ||
dtype = rlz[index].dtype | ||
# TODO add new column to collector, propagate values up to (not incl) current rlz | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a question here. It seems we will not check the duplicate data in the indexes if there length are not the same. If I understand correctly, this will increase the memory and slow down the calculation. Let's talk on Monday.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alfoa I need you comments here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is correct; if the length of the indexes is not the same, then the old index and the new index cannot be exactly the same, so we have to store them separately. Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed in the meeting, can you add "FIXME" here regarding the memory and speed issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done