Skip to content
Snippets Groups Projects

Draft: Resolve "Use Numpy arrays instead of `ForEachObject` instances"

2 unresolved threads

Closes #34 (closed)

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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]
  • 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 Staab
  • That sounds like a good idea. Would you wanna work on that tomorrow, after the simulation meeting?

  • added 2 commits

    • 73bc0a88 - Delete containers.py
    • 6d09ccff - Add possibility to build SC and MOSA arrays from single values

    Compare with previous version

  • Jean-Baptiste Bayle changed milestone to %v1.1

    changed milestone to %v1.1

  • Jean-Baptiste Bayle changed milestone to %v1.2

    changed milestone to %v1.2

  • Jean-Baptiste Bayle added 254 commits

    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

    Compare with previous version

  • 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).

  • Please register or sign in to reply
    Loading