ADR Suggestion
DescriptorArray
#95
Replies: 9 comments 8 replies
-
I think this is all correct but should be converted to a task in the EasyScience project https://github.com/orgs/EasyScience/projects/21 New features, especially extensions of existing functionality are best described on the project board as they are then easy to manage in the workflow TODO -> IN PROGRESS -> DONE |
Beta Was this translation helpful? Give feedback.
-
We will also allow addition etc. with DescriptorNumbers |
Beta Was this translation helpful? Give feedback.
-
Broadcasting operations will be allowed. In particular, broadcasting operations involving variables with variances will not consider the covariances between elements of the array that will be introduced. For example, addition of a |
Beta Was this translation helpful? Give feedback.
-
We need to define what the resulting type should be when performing operations with Numpy arrays. There are two alternatives:
a = np.array(...)
b = DescriptorArray(...)
c = a + b # c is a DescriptorArray
c = b + a # c is a DescriptorArray
a = np.array(...)
b = DescriptorArray(...)
c = a + b # c is a Numpy array
c = b + a # c is a DescriptorArray Option 1 might initially be the most intuitive, but it requires extra complexity in the form of explicitly overriding the Numpy Option 2 is consistent with how unit conversions work, but is not consistent with how operations on other types of objects with DescriptorArrays work. For example, addition with a list always yields a DescriptorArray. In order to implement Option 2, we should implement the This discussion was sparked by an issue I encountered when implementing |
Beta Was this translation helpful? Give feedback.
-
Looking at the kind of rabbit hole this is turning into, I am re-considering the potential use-case for this functionality. While it is easy to try to make a "perfect" class that interfaces with everything, I don't think we want our users to use numpy arrays with our descriptors and parameters. We should encourage, and here force, the users to use scipp arrays or our own classes instead. So I propose to not implement arithmetic operations for numpy arrays. |
Beta Was this translation helpful? Give feedback.
-
We should also support a trace operation for the descriptor array |
Beta Was this translation helpful? Give feedback.
-
Should the |
Beta Was this translation helpful? Give feedback.
-
I am a bit late for this, but I think we need to discuss a bit what the purpose is of However, EasyCrystallography already has a class to handle space group operations, including all the required matrix operations and things I had not even thought to consider such as tolerance*. This is why I made the I am not sure if we have any other use cases for *I believe it's for the following: using all the space group operations might create duplicate atom positions, within some numerical tolerance. For the sake of example, it may create atoms at (0,0,0) and (0.01,0,0), which would be considered equal. |
Beta Was this translation helpful? Give feedback.
-
We will not support editing part of an The reason for this change has to do with us not implementing views for the arr = DescriptorArray(...)
sub_arr = arr['dim0', 0] # also a DescriptorArray Slicing is done using scipp syntax. arr = DescriptorArray(values=[1.0, 1.0])
arr['dim0', 0][0] = 1000.0 # arr['dim0', 0] is a completely new DescriptorArray and scipp array
arr['dim0', 0][0] # Still 1.0 What we would want is for the above syntax to modify the scipp array of For now we decided to drop functionality for See numpy and scipp docs for further details on their respective systems for slicing and views. |
Beta Was this translation helpful? Give feedback.
-
For EasyCrystallography and EasyDiffraction, we need to have Descriptors that are arrays. We agreed that it should be named DescriptorArray.
It will inherit from DescriptorBase, and will be implemented as scipp variables using scipp.array.
It will have all the same methods as DescriptorNumbers, including element wise+,-abs, neg.
We will follow numpy conventions. This means that * and / can only be done with Numbers or DescriptorNumbers, and will be element wise.
Matrix multiplication and division will be implemented as well, using Numpy. We will follow the Numpy naming scheme. Numpy Arrays and DescriptorArrays will be accepted inputs.
Beta Was this translation helpful? Give feedback.
All reactions