Skip to content

np.datetime64("NaT") used in our tests without explicit unit is deprecated #781

Description

@Simon-Will

Description of the issue

When running the tests, I get the warnings below because np.datetime64("NaT") without an explicit time resolution is deprecated since NumPy 2.5.

tests/xml_download/test_utils_write_to_database.py::test_cast_date_columns_to_string
  /home/gorgor/Code/open-MaStR/tests/xml_download/test_utils_write_to_database.py:66: DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+ 1`).Please use a specific unit instead.
    np.datetime64("nat"),

tests/xml_download/test_utils_write_to_database.py::test_cast_date_columns_to_string
  /home/gorgor/Code/open-MaStR/tests/xml_download/test_utils_write_to_database.py:71: DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+ 1`).Please use a specific unit instead.
    np.datetime64("nat"),

tests/xml_download/test_utils_write_to_database.py::test_add_table_to_sqlite_database[add_table_to_sqlite_database]
tests/xml_download/test_utils_write_to_database.py::test_add_table_to_sqlite_database[add_table_to_sqlite_database]
tests/xml_download/test_utils_write_to_database.py::test_add_table_to_sqlite_database[add_table_to_non_sqlite_database]
tests/xml_download/test_utils_write_to_database.py::test_add_table_to_sqlite_database[add_table_to_non_sqlite_database]
  /home/gorgor/Code/open-MaStR/tests/xml_download/test_utils_write_to_database.py:294: DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+ 1`).Please use a specific unit instead.
    "Meldedatum": [np.datetime64("NaT"), np.datetime64("NaT")],

tests/xml_download/test_utils_write_to_database.py::test_add_table_to_sqlite_database[add_table_to_sqlite_database]
tests/xml_download/test_utils_write_to_database.py::test_add_table_to_sqlite_database[add_table_to_sqlite_database]
tests/xml_download/test_utils_write_to_database.py::test_add_table_to_sqlite_database[add_table_to_non_sqlite_database]
tests/xml_download/test_utils_write_to_database.py::test_add_table_to_sqlite_database[add_table_to_non_sqlite_database]
  /home/gorgor/Code/open-MaStR/tests/xml_download/test_utils_write_to_database.py:299: DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+ 1`).Please use a specific unit instead.
    "EegInbetriebnahmedatum": [np.datetime64("NaT"), np.datetime64("NaT")],

tests/xml_download/test_utils_write_to_database.py::test_add_table_to_sqlite_database[add_table_to_sqlite_database]
tests/xml_download/test_utils_write_to_database.py::test_add_table_to_sqlite_database[add_table_to_sqlite_database]
tests/xml_download/test_utils_write_to_database.py::test_add_table_to_sqlite_database[add_table_to_non_sqlite_database]
tests/xml_download/test_utils_write_to_database.py::test_add_table_to_sqlite_database[add_table_to_non_sqlite_database]
  /home/gorgor/Code/open-MaStR/tests/xml_download/test_utils_write_to_database.py:307: DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+ 1`).Please use a specific unit instead.
    "DatumDownload": [np.datetime64("NaT"), np.datetime64("NaT")],

Ideas of solution

We should just use np.datetime("NaT", "D") for places where we expect day resolution and np.datetime("NaT", "s") where we expect second resolution. We probably don't have other cases.

Workflow checklist

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueThis issue is suitable for a first time contribution

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions