Skip to content

Conversation

@javierggt
Copy link
Contributor

@javierggt javierggt commented Dec 4, 2025

Description

This fixes an issue that caused a test failure in chandra_limits. I added a test here, so one does not need to run the chandra_limits test to see it fail. This only addressed the case that failed in chandra_limits.

The issue is that get_ocat_local uses the given arguments to assemble a query on the fly. The query is assembled in a loop:

    for col_name, value in params.items():
        where_parts.append(f"{col_name}=='{value!r}'")

Since numpy 2, this format will create queries like "seq_num=='np.str_('700958')'" instead of "seq_num=='700958'". This PR fixes that and it is backward compatible.

I did grep on !r and these are all the instances left:

mica/archive/cda/services.py:            f"invalid return_type {return_type!r}, must be 'auto' or 'table'"
mica/archive/cda/services.py:            f"unknown service {service!r}, must be one of {list(CDA_SERVICES)}"
mica/archive/cda/services.py:            f"invalid return_type {return_type!r}, must be 'auto' or 'table'"
mica/archive/tests/test_cda.py:        return {"where": f"seq_num=={value!r}"}

The first three are log messages. The last one is a test, and the inputs to the test are never numpy types.

As a side note, I did a search for !r in the sot organization, and found that this format is used in log messages in several places. I can understand it if one wants to log the type of the variable, because sometimes an error happens due to a wrong type, but that is not the norm. Most times I prefer log messages to be more human readable.

Interface impacts

Testing

Unit tests

  • No unit tests
  • Mac
  • Linux
  • Windows
(ska3-flight-2026.0rc4) jgonzale mica $ git rev-parse HEAD
c75e752ab6bd32ae0a2a898dc9f283e0e7ae286a
(ska3-flight-2026.0rc4) jgonzale mica $ pytest mica
==================================================================== test session starts =====================================================================
platform linux -- Python 3.13.10, pytest-9.0.1, pluggy-1.6.0
rootdir: /proj/sot/ska/jgonzalez/git
configfile: pytest.ini
plugins: timeout-2.4.0, anyio-4.12.0
collected 117 items                                                                                                                                          

mica/archive/tests/test_aca_dark_cal.py ..................                                                                                             [ 15%]
mica/archive/tests/test_aca_hdr3.py ..                                                                                                                 [ 17%]
mica/archive/tests/test_aca_l0.py .....                                                                                                                [ 21%]
mica/archive/tests/test_asp_l1.py .......                                                                                                              [ 27%]
mica/archive/tests/test_cda.py ..................................................                                                                      [ 70%]
mica/archive/tests/test_obspar.py .                                                                                                                    [ 70%]
mica/report/tests/test_report.py ..                                                                                                                    [ 72%]
mica/report/tests/test_write_report.py .                                                                                                               [ 73%]
mica/starcheck/tests/test_catalog_fetches.py ...............                                                                                           [ 86%]
mica/stats/tests/test_acq_stats.py ...                                                                                                                 [ 88%]
mica/stats/tests/test_guide_stats.py ....                                                                                                              [ 92%]
mica/vv/tests/test_vv.py .........                                                                                                                     [100%]

====================================================================== warnings summary ======================================================================
mica/mica/archive/tests/test_aca_l0.py::test_get_aca_images
mica/mica/archive/tests/test_aca_l0.py::test_get_aca_images_empty
  /export/jgonzale/miniconda3/envs/ska3-flight-2026.0rc4/lib/python3.13/site-packages/chandra_aca/maude_decom.py:299: RuntimeWarning: overflow encountered in scalar subtract
    return np.int64(np.sum(a * _bits[-n:]) - (1 << n))

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================== 117 passed, 2 warnings in 414.91s (0:06:54) =========================================================

Independent check of unit tests by Jean

  • linux ska3/flight
(ska3-latest) jeanconn-kady> pytest
========================================================= test session starts ==========================================================
platform linux -- Python 3.12.8, pytest-8.3.4, pluggy-1.5.0
rootdir: /proj/sot/ska/jeanproj/git
configfile: pytest.ini
plugins: anyio-4.7.0, timeout-2.3.1
collected 117 items                                                                                                                    

mica/archive/tests/test_aca_dark_cal.py ..................                                                                       [ 15%]
mica/archive/tests/test_aca_hdr3.py ..                                                                                           [ 17%]
mica/archive/tests/test_aca_l0.py .....                                                                                          [ 21%]
mica/archive/tests/test_asp_l1.py .......                                                                                        [ 27%]
mica/archive/tests/test_cda.py ..................................................                                                [ 70%]
mica/archive/tests/test_obspar.py .                                                                                              [ 70%]
mica/report/tests/test_report.py ..                                                                                              [ 72%]
mica/report/tests/test_write_report.py .                                                                                         [ 73%]
mica/starcheck/tests/test_catalog_fetches.py ...............                                                                     [ 86%]
mica/stats/tests/test_acq_stats.py ...                                                                                           [ 88%]
mica/stats/tests/test_guide_stats.py ....                                                                                        [ 92%]
mica/vv/tests/test_vv.py .........                                                                                               [100%]

=========================================================== warnings summary ===========================================================
mica/mica/archive/tests/test_asp_l1.py::test_update_l1_archive
  /export/jeanconn/miniforge3/envs/ska3-latest/lib/python3.12/pty.py:95: DeprecationWarning: This process (pid=634194) is multi-threaded, use of forkpty() may lead to deadlocks in the child.
    pid, fd = os.forkpty()

mica/mica/archive/tests/test_cda.py::test_get_proposal_abstract
mica/mica/archive/tests/test_cda.py::test_get_proposal_abstract
mica/mica/report/tests/test_write_report.py::test_write_reports
mica/mica/report/tests/test_write_report.py::test_write_reports
  /export/jeanconn/miniforge3/envs/ska3-latest/lib/python3.12/site-packages/bs4/builder/_lxml.py:124: DeprecationWarning: The 'strip_cdata' option of HTMLParser() has never done anything and will eventually be removed.
    parser = parser(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================================= 117 passed, 5 warnings in 440.45s (0:07:20) ==============================================

(ska3-latest) jeanconn-kady> git rev-parse HEAD
c75e752ab6bd32ae0a2a898dc9f283e0e7ae286a

Functional tests

No functional testing.

@javierggt javierggt merged commit 2b9963f into master Dec 9, 2025
2 checks passed
This was referenced Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants