-
-
Notifications
You must be signed in to change notification settings - Fork 213
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
Give lat/lon array a str() that doesn’t raise ValueError #524
Comments
Just happened to run across this one while working on #524.
Alas, I don't get that warning on my particular NumPy version that's installed. Could you try putting this at the top of your script?
Then re-run and it should give you a whole exception that you can paste here so we can learn where the error is. Thanks! |
Huh, oddly I'm only seeing this message when using pdb and inspecting either of these variables:
here's the pdb session:
when i run the full script it, that error doesn't get mentioned. also i tried those lines you shared and that didn't seem to make a difference in the issue getting raised to the level of the script. i should mention that this is code in a flask view function/controller:
hmm.. i'll see if google fu for something like "numpy pdb valueerror" turns up any hints. FYI, i'm on the latest numpy (1.19.4) |
Could the issue be that |
indeed! adding those calls to here's an example of some of the traceback for
similarly for
|
Thanks for investigating further! I have edited the title to help me keep up with the specific fix needed here. I guess before the next release I should design how the string representation of a multiple-topographic-location array should show what it is. I wonder if it should print all the coordinates or just say "I represent n locations" and let the user poke inside if they want to see the actual latitudes and elevations etc or maybe instead leave it to NumPy to do any reasonable truncation (in case a user tries printing a location with, say, a thousand latitudes). |
No problem! Thanks for your help. I like the idea of having something "I represent n locations" but the latter option sounds good to me as well, I'm pretty easy going with these things. Taking a look at what the single location str and repr's return:
I do really like this, it is helpful for someone debugging their code. It gives very quick feedback. You could easily go to google just from the output above to validate the result (if possible). Here's an idea that could be nice ergonomically, currently this part of the API works like this:
What if the
You would be able to subscript in addition to getting a clean repr, and str. But I realize this very well may a lot of work and I am probably missing some important tradeoffs. I just wanted to share the idea :-) |
Thanks for the ideas! I'll mull them over and hopefully have my thoughts straight by sometime next week; I'll comment here at that point. |
I have updated this issue title since at its root, I think, is the fact that Skyfield has never handled lat/lon position arrays before (unless there's a spot in the docs and tests where they're used, that I've forgotten about?), and possibly many things need to change to offer them full support. And thus I have also added the label “feature request” so that as I look at my dashboard I can keep track of “existing things that are broken” vs “new things we want to support”! And thus this issue gets drawn into the larger discussion that is taking place over on Pull Requests #526 and #532. My guess is that it’s only once the discussion there has arrived at a consistent approach towards arrays (which will probably take some time; as you'll note, I'm probably only making about one comment a week there, given my other commitments) that we’ll return here and be able to apply that approach to giving geographic positions and their str()'s. So, thanks for your patience! |
FWIW, lat/lon position arrays do seem to "just work". I.e. this code works like a charm:
And yields awesome results like: I would be glad to offer some feedback as well, so feel free to ping me anytime. I'm curious to follow the plans, so will tune in on those PR's. I understand the need for patience and some time, will gladly provide that :-) |
Wow, neat! Thanks for sharing that image! So in your case there are n latitudes and n longitudes corresponding to n times — rather than, say, n locations that all want to do an observation at one single time, or at m times. That does keep things simpler, and I'm glad the current code works just fine, at least with storing those quantities as longitude and latitude array! Given that your use case is working fine, and is a case where all the arrays have the same dimension, I guess the only final step here is the |
There! The str and repr now show something like:
instead of raising
|
Indeed, works like a charm! I was a bit puzzled at first though, I had to use this to pick up the new changes:
Looks nice in the pdb session now :-) Thanks for the fix! If you're curious, I made the image with cartopy. It's not exactly an easy package to install, but once you've got it, it works pretty well. |
I'm glad it's no longer raising the exception for you! I'll have to take a look at cartopy, thanks for linking toit. |
Minimal code to repro:
At that breakpoint you can see the errors by:
I was expecting to get back a list or multiple subpoint objects.
I just realized this is just a warning message and that the code does work as intended. So perhaps this is just a vanity thing to clean up or maybe it's something I've done wrong.
Proof it works as intended:
Perhaps it's just tired eyes, but that message raised a red flag for me. I realize this may be an issue there's not much to do on. But I thought I'd share anyways.
Greatly enjoying this library. Thanks for your work on it :-)
The text was updated successfully, but these errors were encountered: