python-sgp4 icon indicating copy to clipboard operation
python-sgp4 copied to clipboard

fix missing revnum attribute on pure-python Satrec

Open plentydone opened this issue 11 months ago • 1 comments

Failure looks like this:

ERROR: test_export_tle_sgp4init (sgp4.tests.TestFunctions.test_export_tle_sgp4init)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/andrew/python-sgp4/.tox/py312/lib/python3.12/site-packages/sgp4/tests.py", line 252, in test_export_tle_sgp4init
    outline1, outline2 = export_tle(sat)
                         ^^^^^^^^^^^^^^^
  File "/home/andrew/python-sgp4/.tox/py312/lib/python3.12/site-packages/sgp4/exporter.py", line 89, in export_tle
    append(str(satrec.revnum).rjust(5))
               ^^^^^^^^^^^^^
AttributeError: 'Satrec' object has no attribute 'revnum'. Did you mean: 'elnum'?

Let me know if any adjustments are needed.

plentydone avatar Mar 03 '25 18:03 plentydone

Sorry for the spam with the broken tests. I couldn't replicate locally for some reason, will figure out in the next day or two.

plentydone avatar Mar 16 '25 18:03 plentydone

Finally came back to this, saw what I did wrong in the tests, and fixed and expanded them. Hopefully it's all good this time!

plentydone avatar Apr 21 '25 20:04 plentydone

I have finally had time to circle back to this, and in case anyone else's code ever looks for .revnum, I think it makes the most sense for the module to simply guarantee that the attribute is always there:

6d89ae1a8c47f9ad909a11e9cd78c4b328bdba41

Also, I have written a test.sh test script that tests locally whether both the compiled and the pure-Python versions of SGP4 work. That way, we avoid needing to have tests with branches inside that do different things depending on whether the C++ successfully compiled.

brandon-rhodes avatar Jul 29 '25 06:07 brandon-rhodes

Looks great, thanks Brandon!

plentydone avatar Aug 01 '25 13:08 plentydone

I'm hoping to find time next week for a release, to get this feature out. Thanks again for pointing out the problem.

brandon-rhodes avatar Aug 01 '25 15:08 brandon-rhodes