question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

These won't always be exactly equal

See original GitHub issue

https://github.com/ngageoint/sarpy/blob/ec54673e089f972c2b740b00cb45b0651940a735/sarpy/consistency/cphd_consistency.py#L1225

srp comes from the PVP parameters which are double precision floating point.

iarp comes from the XML string representation which has limited significant digits.

There are a few solutions:

  • np.around(srp, digits=9)
  • print more significant digits in the XML

I lean towards the first one. If someone doesn’t use sarpy to create the CPHD (as I did) this could still fail.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mtrachycommented, Oct 25, 2021

I think the most elegant solution is to change https://github.com/ngageoint/sarpy/blob/ec54673e089f972c2b740b00cb45b0651940a735/sarpy/consistency/cphd_consistency.py#L1121 to

            if issubclass(np.asarray(expected_value).dtype.type, numbers.Number):

that way any number or array of numbers is being compared using a con.Approx which uses np.isclose under the hood.

Then the changes to this file from an earlier commit: https://github.com/ngageoint/sarpy/commit/41d2260dc876e682dea77a49ce555ea0ddb48670#diff-40594572e8169b144e447ae57d6c93a6aaf047a43dd46de34a46f592874e9c67

could be rolled back. The change to let atol = 1e-6 should probably be kept.

0reactions
mstewart-vsccommented, Oct 25, 2021

It’s not clear which line is causing the failure, but it’s possible that it is this assert here:

https://github.com/ngageoint/sarpy/blob/ec54673e089f972c2b740b00cb45b0651940a735/sarpy/consistency/cphd_consistency.py#L1126

I believe changing the assert to the following is more appropriate and might fix the problem @klucar is encountering, but I can’t be sure without the problematic test data.

                assert np.allclose(expected_value, actual_value, **approx_args)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Two Plus Two Does Not Always Equal Four - The Nickel Report
But two plus two may not equal four due to two concepts: significant figures and rounding.
Read more >
Here's How Your Watch Can Prove That 2 + 2 Doesn't Equal 4
It does not have to be limited to Modulo 12 like with the clock with the ... This is just like with the...
Read more >
Correlation does not imply causation - Wikipedia
This fallacy is also known by the Latin phrase cum hoc ergo propter hoc ('with this, therefore because of this'). This differs from...
Read more >
Inaugural Address by President Barack Obama | whitehouse.gov
We recall that what binds this nation together is not the colors of ... It does not mean we all define liberty in...
Read more >
Equity vs. Equality: What's the Difference?
allocates the exact resources and opportunities needed to reach an equal ... “The route to achieving equity will not be accomplished through treating...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found