-
Notifications
You must be signed in to change notification settings - Fork 31
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
feat: allow coord values in to_<coord_names> methods #446
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #446 +/- ##
=======================================
Coverage 86.38% 86.38%
=======================================
Files 96 96
Lines 11139 11139
=======================================
Hits 9622 9622
Misses 1517 1517 ☔ View full report in Codecov by Sentry. |
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.
Okay, when embedding a vector (or array of vectors) in a larger-dimensional space, you're providing the ability to assign the new coordinate, rather than have it be imputed to be zero. That's a good idea.
As a nice use-case: when embedding 2D into 3D, if the new coordinate is z
, chances are that a user is going to want that coordinate to be zero, but if it's theta
, zero would make as much sense as
In principle, a user might want to assign a whole array of new parameter values, rather than a single constant, in the case of an array of vectors. But that would be a more complicated interface, and there's value to keeping interfaces simple until required to be more complex. This interface can be expanded from scalar new parameters to array new parameters at any point in the future.
No, defaults need to be guessable or memorable, and "default is always zero" is memorable, at least. I brought it up as an example in which someone would legitimately want to change the default.
That's great! I had missed that. So much the better. But would it work with a nested Awkward Array of vectors and a broadcastable array of new |
befe0f3
to
6c08b82
Compare
I missed your comment. I think you ended up editing my comment instead of replying, haha! It works for nested awkward array of vectors too: In [2]: v = vector.Array(
...: [
...: [{"x": 1, "y": 1.1, "z": 0.1}, {"x": 2, "y": 2.2, "z": 0.2}],
...: [],
...: [{"x": 3, "y": 3.3, "z": 0.3}],
...: [
...: {"x": 4, "y": 4.4, "z": 0.4},
...: {"x": 5, "y": 5.5, "z": 0.5},
...: {"x": 6, "y": 6.6, "z": 0.6},
...: ],
...: ]
...: )
In [3]:
In [3]: v
Out[3]: <VectorArray3D [[{x: 1, y: 1.1, ...}, {...}], ...] type='4 * var * Vector3D...'>
In [4]: v.to_Vector4D(t=5)["t"]
Out[4]: <Array [[5, 5], [], [5], [5, 5, 5]] type='4 * var * int64'>
In [5]: v.to_Vector3D().to_Vector4D(t=[[2, 3], [], [4], [5, 6, 7]])["t"]
Out[5]: <Array [[2, 3], [], [4], [5, 6, 7]] type='4 * var * int64'> Is there a specific example that I should try out? |
That example does it! You're hiding the full array between the output of the |
Thanks! TIL there is a In [13]: v.to_Vector3D().to_Vector4D(t=[[2, 3], [], [4], [5, 6, 7]]).show(type=True)
type: 4 * var * Vector4D[
x: int64,
y: float64,
z: float64,
t: int64
]
[[{x: 1, y: 1.1, z: 0.1, t: 2}, {x: 2, y: 2.2, z: 0.2, t: 3}],
[],
[{x: 3, y: 3.3, z: 0.3, t: 4}],
[{x: 4, y: 4.4, z: 0.4, t: 5}, {...}, {x: 6, y: 6.6, z: 0.6, t: 7}]] |
* feat: allow coord values in to_<coord_names> methods * Typos
Description
This is a step in the direction of adding a sympy backend (so that users can pass a
sympy.Symbol
to these methods) and a useful feature to have for all the backends.Checklist
$ pre-commit run --all-files
or$ nox -s lint
)$ pytest
or$ nox -s tests
)$ cd docs; make clean; make html
or$ nox -s docs
)$ pytest --doctest-plus src/vector/
or$ nox -s doctests
)Before Merging