LightCurve objects store differently in numpy arrays following version 1.2
See original GitHub issueProblem description
LightCurve objects explode into objects for each row in time/flux when being put into numpy arrays in version 1.2 and above. Before they would just be stored as one LightCurve object. Could this be to do with the changes implemented in #532?
Is there a way to modify my code so that I can store a LightCurve object in a numpy array in the same way as before v1.2? Or, is this a bug / unforeseen impact relating to recent changes to Lightkurve?
Example
import numpy as np
import lightkurve as lk
lc = lk.LightCurve(np.linspace(0, 1, 100), np.random.normal(1.0, 0.01, 100))
print(np.array([lc]))
This outputs:
[[<lightkurve.lightcurve.LightCurve object at 0x102cab490>
<lightkurve.lightcurve.LightCurve object at 0x102cab690>
<lightkurve.lightcurve.LightCurve object at 0x102cab890>
...
<lightkurve.lightcurve.LightCurve object at 0x102cb9850>
<lightkurve.lightcurve.LightCurve object at 0x102cb98d0>
<lightkurve.lightcurve.LightCurve object at 0x102cb9950>]]
(ellipses added in as output is 100 lines long).
Expected behavior
Before version 1.2, this would just output the following:
[<lightkurve.lightcurve.LightCurve object at 0x7fda3f0b6470>]
Environment
- platform: MacOS 10.15 and CentOS Linux 7
- lightkurve version: 1.2 and 1.3
- installation method: pip
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Stingray API — stingray v1.1.2.dev8+gdfd899c
A list or array of time stamps for a light curve. Must be a type that can be cast to :class:np.array or :class:List...
Read more >NumPy: the absolute basics for beginners
Unlike the typical container objects, different arrays can share the same data, so changes made on one array might be visible in another....
Read more >1.4.1. The NumPy array object
Python objects: ... extension package to Python for multi-dimensional arrays ... Different data-types allow us to store data more compactly in memory, ...
Read more >Source code for lightkurve.lightcurve
`LightCurve` objects also provide user-friendly attribute access to ... None: raise AssertionError("data should be a numpy structured array") if "time" not ...
Read more >4. NumPy Basics: Arrays and Vectorized Computation
Here are some of the things it provides: ndarray , a fast and space-efficient multidimensional array providing vectorized arithmetic operations and ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ha! That’s interesting! The behavior appears to have changed because we added the
LightCurve.__len__
method in #532, which triggersnp.array
to treat a LightCurve as an iterable.A work-around is to do the following:
@alexlyttle Would you be willing to provide a bit more background as to why you are interested in being able to have numpy arrays contain Lightcurve objects?
Thanks @alexlyttle! We appreciate your feedback!! 🙏