Draft: Resolve "Use Numpy arrays instead of `ForEachObject` instances"
Closes #34 (closed)
Merge request reports
Activity
changed milestone to %v1.0
added documentation label
added 6 commits
Toggle commit listadded 1 commit
- 405d0ba0 - Add methods to convert dictionary to MOSA and SC arrays
mentioned in issue #34 (closed)
added 3 commits
-
02d1166a...e2724e3e - 2 commits from branch
master
- 2dc661bc - Implement indexing functions and unit tests
-
02d1166a...e2724e3e - 2 commits from branch
- lisainstrument/indexing.py 0 → 100644
59 60 return np.stack(tuple(x_int[sc] for sc in keys), axis=axis) 61 62 63 def dict2mosa(x, axis=0): 64 """Return a new array whose `axis` is for spacecraft and `axis + 1` for MOSAs, with content of `x`. 65 66 The keys of `x` should be [12, 23, 31, 13, 32, 21] (or convertible to those), and values array-like. 67 68 Note that all values of `x` should have the same shape, or can be automatically broadcasted. 69 If they have shape (N), the resulting array will be of shape (3, 2, N) by default (first axis). 70 71 Args: 72 x: input dictionary 73 """ 74 mosas = [12, 23, 31, 13, 32, 21] I thought a bit about it, and I don't see why we can't do that…
Also, we convert nicely between, say, strings and integer, so users can use both.
Edited by Jean-Baptiste Bayle
- lisainstrument/indexing.py 0 → 100644
84 85 def sc2dict(x, axis=0): 86 """Return a dictionary whose keys are spacecraft indices, from array `x`. 87 88 The array `x` must have `axis` of dimension 3, ordered as [SC1, SC2, SC3]. 89 90 The output dictionary containes the keys [1, 2, 3]. 91 92 Args: 93 x: array-like input 94 """ 95 if x.shape[axis] != 3: 96 raise IndexError(f"invalid size '{x.shape[axis]}' for spacecraft dimension '{axis}'") 97 98 return { 99 1: np.take(x, SC1, axis=axis), Hi @j2b.bayle,
this looks great! I think we can start now reworking the code. Let me know how you plan to do this and where I can help!
I think a first step could be to just replace all containers by arrays. In a second step we can try to bundle up the different properties like MOD, IFO, ... to make the code more readable... What do you think?
Edited by Martin Staabchanged milestone to %v1.1
changed milestone to %v1.2
added 254 commits
-
6d09ccff...1f895a5b - 251 commits from branch
master
- c1b60a76 - Implement indexing functions and unit tests
- 833653a0 - Delete containers.py
- e08d1b90 - Add possibility to build SC and MOSA arrays from single values
Toggle commit list-
6d09ccff...1f895a5b - 251 commits from branch
mentioned in issue #106
Keeping the branch alive to support #106, but closing this as this would increase the runtime once #107 (closed) is solved (more easily).