Skip to content
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

ENH: _testing.assert_almost_equal on datetimes actually checks exact equality #50191

Open
3 tasks done
rebecca-palmer opened this issue Dec 11, 2022 · 4 comments
Open
3 tasks done
Labels
Error Reporting Incorrect or improved errors from pandas Testing pandas testing functions or related to the test suite

Comments

@rebecca-palmer
Copy link
Contributor

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

#from 535a4ecd0756e498e958d0cf9e92b23dd9c26438 (#50183)
        oneyear_in_ns = 1e9 * 60 * 60 * 24 * 365.2425
        tsmax_in_years = 2**63 / oneyear_in_ns  # 2**63 ns, in years
        # just in bounds
        should_succeed = Series(
            [0, tsmax_in_years - 0.05, -tsmax_in_years + 0.05], dtype=float
        )
        expected = (should_succeed * oneyear_in_ns).astype("M8[ns]")
        for error_mode in ["raise", "coerce", "ignore"]:
            result1 = to_datetime(should_succeed, unit="Y", errors=error_mode)
            tm.assert_almost_equal(result1, expected, rtol=1e-10)

Issue Description

_testing.assert_almost_equal on datetimes (and probably other extension types) actually checks exact equality, because pandas/_testing/asserters.py:731 calls assert_numpy_array_equal, which doesn't have atol/rtol.

I'm not sure what should be done about this: it looks like removing that call or restricting it to check_exact=True would instead create an infinite loop, though I haven't actually tested that.

Failure log:

=================================== FAILURES ===================================
_________ TestToDatetimeUnit.test_float_to_datetime_raise_near_bounds __________
[gw0] linux -- Python 3.8.15 /home/runner/micromamba/envs/test/bin/python3.8

self = <pandas.tests.tools.test_to_datetime.TestToDatetimeUnit object at 0x7face2178cd0>

    def test_float_to_datetime_raise_near_bounds(self):
        msg = "cannot convert input with unit 'Y'"
        oneyear_in_ns = 1e9 * 60 * 60 * 24 * 365.2425
        tsmax_in_years = 2**63 / oneyear_in_ns  # 2**63 ns, in years
        # just in bounds
        should_succeed = Series(
            [0, tsmax_in_years - 0.05, -tsmax_in_years + 0.05], dtype=float
        )
        expected = (should_succeed * oneyear_in_ns).astype("M8[ns]")
        for error_mode in ["raise", "coerce", "ignore"]:
            result1 = to_datetime(should_succeed, unit="Y", errors=error_mode)
>           tm.assert_almost_equal(result1, expected, rtol=1e-10)

pandas/tests/tools/test_to_datetime.py:1643: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pandas/_testing/asserters.py:100: in assert_almost_equal
    assert_series_equal(
pandas/_testing/asserters.py:731: in assert_extension_array_equal
    assert_numpy_array_equal(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

left = array([                   0,  9221794189257056904, -9221794189257056904])
right = array([                   0,  9221794189254774784, -9221794189254774784])
err_msg = None

    def _raise(left, right, err_msg):
        if err_msg is None:
            if left.shape != right.shape:
                raise_assert_detail(
                    obj, f"{obj} shapes are different", left.shape, right.shape
                )
    
            diff = 0
            for left_arr, right_arr in zip(left, right):
                # count up differences
                if not array_equivalent(left_arr, right_arr, strict_nan=strict_nan):
                    diff += 1
    
            diff = diff * 100.0 / left.size
            msg = f"{obj} values are different ({np.round(diff, 5)} %)"
>           raise_assert_detail(obj, msg, left, right, index_values=index_values)
E           AssertionError: numpy array are different
E           
E           numpy array values are different (66.66667 %)
E           [index]: [0, 1, 2]
E           [left]:  [0, 9221794189257056904, -9221794189257056904]
E           [right]: [0, 9221794189254774784, -9221794189254774784]

pandas/_testing/asserters.py:662: AssertionError

Expected Behavior

As the values are within the specified tolerance of each other, assert_almost_equal should pass.

(It's possibly also a bug that to_datetime(errors='raise') and to_datetime(errors='coerce') are rounded differently, but a separate one.)

Installed Versions

Probably not critical since all the CI runs failed.

(It looks like the bug also exists in stable, but I haven't actually tested that - I assume your bug reporting form's "version checks" aren't actually intended to ban reporting bugs that exist in main but not in a release.)

  /usr/bin/bash -lc micromamba list --log-level warning
  List of packages in environment: "/home/runner/micromamba/envs/test"
  
    Name                                Version       Build                Channel    
  ──────────────────────────────────────────────────────────────────────────────────────
    _ipython_minor_entry_point          8.7.0         h3b92ee0_0           conda-forge
    _libgcc_mutex                       0.1           conda_forge          conda-forge
    _openmp_mutex                       4.5           2_gnu                conda-forge
    aiobotocore                         2.4.0         pyhd8ed1ab_0         conda-forge
    aiohttp                             3.8.3         py38h0a891b7_1       conda-forge
    aioitertools                        0.11.0        pyhd8ed1ab_0         conda-forge
    aiosignal                           1.3.1         pyhd8ed1ab_0         conda-forge
    alsa-lib                            1.2.8         h166bdaf_0           conda-forge
    arrow-cpp                           7.0.1         py38h516eea7_10_cpu  conda-forge
    asttokens                           2.2.1         pyhd8ed1ab_0         conda-forge
    async-timeout                       4.0.2         pyhd8ed1ab_0         conda-forge
    attr                                2.5.1         h166bdaf_1           conda-forge
    attrs                               22.1.0        pyh71513ae_1         conda-forge
    aws-c-cal                           0.5.11        h95a6274_0           conda-forge
    aws-c-common                        0.6.2         h7f98852_0           conda-forge
    aws-c-event-stream                  0.2.7         h3541f99_13          conda-forge
    aws-c-io                            0.10.5        hfb6a706_0           conda-forge
    aws-checksums                       0.1.11        ha31a3da_7           conda-forge
    aws-sdk-cpp                         1.8.186       hecaee15_4           conda-forge
    backcall                            0.2.0         pyh9f0ad1d_0         conda-forge
    backports                           1.0           pyhd8ed1ab_3         conda-forge
    backports.functools_lru_cache       1.6.4         pyhd8ed1ab_0         conda-forge
    backports.zoneinfo                  0.2.1         py38h0a891b7_7       conda-forge
    beautifulsoup4                      4.11.1        pyha770c72_0         conda-forge
    blinker                             1.5           pyhd8ed1ab_0         conda-forge
    blosc                               1.21.2        hafa529b_0           conda-forge
    boost-cpp                           1.78.0        h75c5d50_1           conda-forge
    boto3                               1.24.59       pyhd8ed1ab_0         conda-forge
    botocore                            1.27.59       pyhd8ed1ab_0         conda-forge
    bottleneck                          1.3.5         py38h26c90d9_1       conda-forge
    branca                              0.6.0         pyhd8ed1ab_0         conda-forge
    brotli                              1.0.9         h166bdaf_8           conda-forge
    brotli-bin                          1.0.9         h166bdaf_8           conda-forge
    brotlipy                            0.7.0         py38h0a891b7_1005    conda-forge
    bzip2                               1.0.8         h7f98852_4           conda-forge
    c-ares                              1.18.1        h7f98852_0           conda-forge
    ca-certificates                     2022.12.7     ha878542_0           conda-forge
    cachetools                          5.2.0         pyhd8ed1ab_0         conda-forge
    cairo                               1.16.0        ha61ee94_1014        conda-forge
    certifi                             2022.12.7     pyhd8ed1ab_0         conda-forge
    cffi                                1.15.1        py38h4a40e3a_2       conda-forge
    cfitsio                             4.2.0         hd9d235c_0           conda-forge
    charset-normalizer                  2.1.1         pyhd8ed1ab_0         conda-forge
    click                               8.1.3         unix_pyhd8ed1ab_2    conda-forge
    click-plugins                       1.1.1         py_0                 conda-forge
    cligj                               0.7.2         pyhd8ed1ab_1         conda-forge
    colorama                            0.4.6         pyhd8ed1ab_0         conda-forge
    contourpy                           1.0.6         py38h43d8883_0       conda-forge
    coverage                            6.5.0         py38h0a891b7_1       conda-forge
    cramjam                             2.6.2         py38h0287bc9_0       conda-forge
    cryptography                        38.0.4        py38h2b5fc30_0       conda-forge
    curl                                7.86.0        h7bff187_1           conda-forge
    cycler                              0.11.0        pyhd8ed1ab_0         conda-forge
    cython                              0.29.32       py38hfa26641_1       conda-forge
    db-dtypes                           1.0.5         pyhd8ed1ab_0         conda-forge
    dbus                                1.13.6        h5008d03_3           conda-forge
    decorator                           5.1.1         pyhd8ed1ab_0         conda-forge
    defusedxml                          0.7.1         pyhd8ed1ab_0         conda-forge
    et_xmlfile                          1.0.1         py_1001              conda-forge
    exceptiongroup                      1.0.4         pyhd8ed1ab_0         conda-forge
    execnet                             1.9.0         pyhd8ed1ab_0         conda-forge
    executing                           1.2.0         pyhd8ed1ab_0         conda-forge
    expat                               2.5.0         h27087fc_0           conda-forge
    fastavro                            1.7.0         py38h0a891b7_0       conda-forge
    fastparquet                         2022.12.0     py38h7e4f40d_0       conda-forge
    fftw                                3.3.10        nompi_hf0379b8_106   conda-forge
    fiona                               1.8.22        py38hc72d8cd_2       conda-forge
    folium                              0.13.0        pyhd8ed1ab_0         conda-forge
    font-ttf-dejavu-sans-mono           2.37          hab24e00_0           conda-forge
    font-ttf-inconsolata                3.000         h77eed37_0           conda-forge
    font-ttf-source-code-pro            2.038         h77eed37_0           conda-forge
    font-ttf-ubuntu                     0.83          hab24e00_0           conda-forge
    fontconfig                          2.14.1        hc2a2eb6_0           conda-forge
    fonts-conda-ecosystem               1             0                    conda-forge
    fonts-conda-forge                   1             0                    conda-forge
    fonttools                           4.38.0        py38h0a891b7_1       conda-forge
    freetype                            2.12.1        hca18f0e_1           conda-forge
    freexl                              1.0.6         h166bdaf_1           conda-forge
    frozenlist                          1.3.3         py38h0a891b7_0       conda-forge
    fsspec                              2022.11.0     pyhd8ed1ab_0         conda-forge
    gcsfs                               2022.11.0     pyhd8ed1ab_0         conda-forge
    gdal                                3.5.3         py38h1f15b03_4       conda-forge
    geopandas                           0.12.2        pyhd8ed1ab_0         conda-forge
    geopandas-base                      0.12.2        pyha770c72_0         conda-forge
    geos                                3.11.1        h27087fc_0           conda-forge
    geotiff                             1.7.1         ha76d385_4           conda-forge
    gettext                             0.21.1        h27087fc_0           conda-forge
    gflags                              2.2.2         he1b5a44_1004        conda-forge
    giflib                              5.2.1         h36c2ea0_2           conda-forge
    glib                                2.74.1        h6239696_1           conda-forge
    glib-tools                          2.74.1        h6239696_1           conda-forge
    glog                                0.6.0         h6f12383_0           conda-forge
    google-api-core                     2.11.0        pyhd8ed1ab_0         conda-forge
    google-api-core-grpc                2.11.0        hd8ed1ab_0           conda-forge
    google-auth                         2.15.0        pyh1a96a4e_0         conda-forge
    google-auth-oauthlib                0.7.1         pyhd8ed1ab_0         conda-forge
    google-cloud-bigquery               3.1.0         pyhd8ed1ab_0         conda-forge
    google-cloud-bigquery-core          3.1.0         pyhd8ed1ab_0         conda-forge
    google-cloud-bigquery-storage       2.11.0        pyh6c4a22f_0         conda-forge
    google-cloud-bigquery-storage-core  2.11.0        pyh6c4a22f_0         conda-forge
    google-cloud-core                   2.3.2         pyhd8ed1ab_0         conda-forge
    google-cloud-storage                2.7.0         pyh1a96a4e_0         conda-forge
    google-crc32c                       1.1.2         py38h57c428a_4       conda-forge
    google-resumable-media              2.4.0         pyhd8ed1ab_0         conda-forge
    googleapis-common-protos            1.57.0        pyhd8ed1ab_3         conda-forge
    greenlet                            2.0.1         py38hfa26641_0       conda-forge
    grpcio                              1.51.1        py38h7dc2bf5_0       conda-forge
    grpcio-status                       1.51.1        pyhd8ed1ab_0         conda-forge
    gst-plugins-base                    1.21.2        h3e40eee_0           conda-forge
    gstreamer                           1.21.2        hd4edc92_0           conda-forge
    gstreamer-orc                       0.4.33        h166bdaf_0           conda-forge
    hdf4                                4.2.15        h9772cbc_5           conda-forge
    hdf5                                1.12.2        nompi_h2386368_100   conda-forge
    html5lib                            1.1           pyh9f0ad1d_0         conda-forge
    hypothesis                          6.60.0        pyha770c72_0         conda-forge
    icu                                 70.1          h27087fc_0           conda-forge
    idna                                3.4           pyhd8ed1ab_0         conda-forge
    importlib-metadata                  5.1.0         pyha770c72_0         conda-forge
    iniconfig                           1.1.1         pyh9f0ad1d_0         conda-forge
    ipython                             8.7.0         pyh41d4057_0         conda-forge
    jack                                1.9.21        h583fa2b_2           conda-forge
    jedi                                0.18.2        pyhd8ed1ab_0         conda-forge
    jinja2                              3.1.2         pyhd8ed1ab_1         conda-forge
    jmespath                            1.0.1         pyhd8ed1ab_0         conda-forge
    joblib                              1.2.0         pyhd8ed1ab_0         conda-forge
    jpeg                                9e            h166bdaf_2           conda-forge
    json-c                              0.16          hc379101_0           conda-forge
    kealib                              1.4.15        ha7026e8_1           conda-forge
    keyutils                            1.6.1         h166bdaf_0           conda-forge
    kiwisolver                          1.4.4         py38h43d8883_1       conda-forge
    krb5                                1.19.3        h3790be6_0           conda-forge
    lame                                3.100         h166bdaf_1003        conda-forge
    lcms2                               2.14          h6ed2654_0           conda-forge
    ld_impl_linux-64                    2.39          hcc3a1bd_1           conda-forge
    lerc                                4.0.0         h27087fc_0           conda-forge
    libabseil                           20220623.0    cxx17_h05df665_6     conda-forge
    libblas                             3.9.0         16_linux64_openblas  conda-forge
    libbrotlicommon                     1.0.9         h166bdaf_8           conda-forge
    libbrotlidec                        1.0.9         h166bdaf_8           conda-forge
    libbrotlienc                        1.0.9         h166bdaf_8           conda-forge
    libcap                              2.66          ha37c62d_0           conda-forge
    libcblas                            3.9.0         16_linux64_openblas  conda-forge
    libclang                            15.0.6        default_h2e3cab8_0   conda-forge
    libclang13                          15.0.6        default_h3a83d3e_0   conda-forge
    libcrc32c                           1.1.2         h9c3ff4c_0           conda-forge
    libcst                              0.4.9         py38h4029515_0       conda-forge
    libcups                             2.3.3         h3e49a29_2           conda-forge
    libcurl                             7.86.0        h7bff187_1           conda-forge
    libdap4                             3.20.6        hd7c4107_2           conda-forge
    libdb                               6.2.32        h9c3ff4c_0           conda-forge
    libdeflate                          1.14          h166bdaf_0           conda-forge
    libedit                             3.1.20191231  he28a2e2_2           conda-forge
    libev                               4.33          h516909a_1           conda-forge
    libevent                            2.1.10        h9b69904_4           conda-forge
    libffi                              3.4.2         h7f98852_5           conda-forge
    libflac                             1.4.2         h27087fc_0           conda-forge
    libgcc-ng                           12.2.0        h65d4601_19          conda-forge
    libgcrypt                           1.10.1        h166bdaf_0           conda-forge
    libgdal                             3.5.3         hcb70f40_4           conda-forge
    libgfortran-ng                      12.2.0        h69a702a_19          conda-forge
    libgfortran5                        12.2.0        h337968e_19          conda-forge
    libglib                             2.74.1        h606061b_1           conda-forge
    libgomp                             12.2.0        h65d4601_19          conda-forge
    libgoogle-cloud                     2.5.0         h5d50b59_1           conda-forge
    libgpg-error                        1.45          hc0c96e0_0           conda-forge
    libgrpc                             1.51.1        h05bd8bd_0           conda-forge
    libiconv                            1.17          h166bdaf_0           conda-forge
    libkml                              1.3.0         h37653c0_1015        conda-forge
    liblapack                           3.9.0         16_linux64_openblas  conda-forge
    libllvm11                           11.1.0        he0ac6c6_5           conda-forge
    libllvm15                           15.0.6        h63197d8_0           conda-forge
    libnetcdf                           4.8.1         nompi_h261ec11_106   conda-forge
    libnghttp2                          1.47.0        hdcd2b5c_1           conda-forge
    libnsl                              2.0.0         h7f98852_0           conda-forge
    libogg                              1.3.4         h7f98852_1           conda-forge
    libopenblas                         0.3.21        pthreads_h78a6416_3  conda-forge
    libopus                             1.3.1         h7f98852_1           conda-forge
    libpng                              1.6.39        h753d276_0           conda-forge
    libpq                               14.5          h72a31a5_3           conda-forge
    libprotobuf                         3.21.11       h3eb15da_0           conda-forge
    librttopo                           1.1.0         ha49c73b_12          conda-forge
    libsndfile                          1.1.0         hcb278e6_1           conda-forge
    libspatialindex                     1.9.3         h9c3ff4c_4           conda-forge
    libspatialite                       5.0.1         h7c8129e_22          conda-forge
    libsqlite                           3.40.0        h753d276_0           conda-forge
    libssh2                             1.10.0        haa6b8db_3           conda-forge
    libstdcxx-ng                        12.2.0        h46fd767_19          conda-forge
    libsystemd0                         252           h2a991cd_0           conda-forge
    libthrift                           0.16.0        h491838f_2           conda-forge
    libtiff                             4.4.0         h55922b4_4           conda-forge
    libtool                             2.4.6         h9c3ff4c_1008        conda-forge
    libudev1                            252           h166bdaf_0           conda-forge
    libutf8proc                         2.8.0         h166bdaf_0           conda-forge
    libuuid                             2.32.1        h7f98852_1000        conda-forge
    libvorbis                           1.3.7         h9c3ff4c_0           conda-forge
    libwebp-base                        1.2.4         h166bdaf_0           conda-forge
    libxcb                              1.13          h7f98852_1004        conda-forge
    libxkbcommon                        1.0.3         he3ba5ed_0           conda-forge
    libxml2                             2.10.3        h7463322_0           conda-forge
    libxslt                             1.1.37        h873f0b0_0           conda-forge
    libzip                              1.9.2         hc869a4a_1           conda-forge
    libzlib                             1.2.13        h166bdaf_4           conda-forge
    llvmlite                            0.39.1        py38h38d86a4_1       conda-forge
    lxml                                4.9.1         py38ha9ef780_1       conda-forge
    lz4-c                               1.9.3         h9c3ff4c_1           conda-forge
    lzo                                 2.10          h516909a_1000        conda-forge
    mapclassify                         2.4.3         pyhd8ed1ab_0         conda-forge
    markupsafe                          2.1.1         py38h0a891b7_2       conda-forge
    matplotlib                          3.6.2         py38h578d9bd_0       conda-forge
    matplotlib-base                     3.6.2         py38hb021067_0       conda-forge
    matplotlib-inline                   0.1.6         pyhd8ed1ab_0         conda-forge
    mpg123                              1.31.1        h27087fc_0           conda-forge
    multidict                           6.0.2         py38h0a891b7_2       conda-forge
    munch                               2.5.0         py_0                 conda-forge
    munkres                             1.1.4         pyh9f0ad1d_0         conda-forge
    mypy_extensions                     0.4.3         py38h578d9bd_6       conda-forge
    mysql-common                        8.0.31        haf5c9bc_0           conda-forge
    mysql-libs                          8.0.31        h28c427c_0           conda-forge
    ncurses                             6.3           h27087fc_1           conda-forge
    networkx                            2.8.8         pyhd8ed1ab_0         conda-forge
    nomkl                               1.0           h5ca1d4c_0           conda-forge
    nspr                                4.35          h27087fc_0           conda-forge
    nss                                 3.82          he02c5a1_0           conda-forge
    numba                               0.56.4        py38h9a4aae9_0       conda-forge
    numexpr                             2.8.3         py38h36ff5c2_101     conda-forge
    numpy                               1.23.5        py38h7042d01_0       conda-forge
    oauthlib                            3.2.2         pyhd8ed1ab_0         conda-forge
    odfpy                               1.4.1         py_0                 conda-forge
    openjpeg                            2.5.0         h7d73246_1           conda-forge
    openpyxl                            3.0.10        py38h0a891b7_2       conda-forge
    openssl                             1.1.1s        h0b41bf4_1           conda-forge
    orc                                 1.8.0         h09e0d61_0           conda-forge
    packaging                           22.0          pyhd8ed1ab_0         conda-forge
    pandas                              1.5.2         py38h8f669ce_0       conda-forge
    pandas-gbq                          0.17.9        pyh1a96a4e_0         conda-forge
    parquet-cpp                         1.5.1         2                    conda-forge
    parso                               0.8.3         pyhd8ed1ab_0         conda-forge
    pcre                                8.45          h9c3ff4c_0           conda-forge
    pcre2                               10.40         hc3806b6_0           conda-forge
    pexpect                             4.8.0         pyh1a96a4e_2         conda-forge
    pickleshare                         0.7.5         py_1003              conda-forge
    pillow                              9.2.0         py38h9eb91d8_3       conda-forge
    pip                                 22.3.1        pyhd8ed1ab_0         conda-forge
    pixman                              0.40.0        h36c2ea0_0           conda-forge
    pluggy                              1.0.0         pyhd8ed1ab_5         conda-forge
    ply                                 3.11          py_1                 conda-forge
    poppler                             22.11.0       h92391eb_0           conda-forge
    poppler-data                        0.4.11        hd8ed1ab_0           conda-forge
    postgresql                          14.5          h5bbe9e2_3           conda-forge
    proj                                9.1.0         h93bde94_0           conda-forge
    prompt-toolkit                      3.0.36        pyha770c72_0         conda-forge
    proto-plus                          1.22.1        pyhd8ed1ab_0         conda-forge
    protobuf                            4.21.11       py38h8dc9893_0       conda-forge
    psutil                              5.9.4         py38h0a891b7_0       conda-forge
    psycopg2                            2.9.3         py38h0a891b7_1       conda-forge
    pthread-stubs                       0.4           h36c2ea0_1001        conda-forge
    ptyprocess                          0.7.0         pyhd3deb0d_0         conda-forge
    pulseaudio                          16.1          h4a94279_0           conda-forge
    pure_eval                           0.2.2         pyhd8ed1ab_0         conda-forge
    pyarrow                             7.0.1         py38h05fcbbb_10_cpu  conda-forge
    pyasn1                              0.4.8         py_0                 conda-forge
    pyasn1-modules                      0.2.7         py_0                 conda-forge
    pycparser                           2.21          pyhd8ed1ab_0         conda-forge
    pydata-google-auth                  1.4.0         pyhd8ed1ab_0         conda-forge
    pygments                            2.13.0        pyhd8ed1ab_0         conda-forge
    pyjwt                               2.6.0         pyhd8ed1ab_0         conda-forge
    pymysql                             1.0.2         pyhd8ed1ab_0         conda-forge
    pyopenssl                           22.1.0        pyhd8ed1ab_0         conda-forge
    pyparsing                           3.0.9         pyhd8ed1ab_0         conda-forge
    pyproj                              3.4.0         py38hce0a2d1_2       conda-forge
    pyqt                                5.15.7        py38h7492b6b_2       conda-forge
    pyqt5-sip                           12.11.0       py38hfa26641_2       conda-forge
    pyreadstat                          1.2.0         py38he5536e0_1       conda-forge
    pysocks                             1.7.1         pyha2e5f31_6         conda-forge
    pytables                            3.7.0         py38hf134f34_3       conda-forge
    pytest                              7.2.0         pyhd8ed1ab_2         conda-forge
    pytest-asyncio                      0.20.3        pyhd8ed1ab_0         conda-forge
    pytest-cov                          4.0.0         pyhd8ed1ab_0         conda-forge
    pytest-xdist                        3.1.0         pyhd8ed1ab_0         conda-forge
    python                              3.8.15        h257c98d_0_cpython   conda-forge
    python-dateutil                     2.8.2         pyhd8ed1ab_0         conda-forge
    python-snappy                       0.6.1         py38h1ddbb56_0       conda-forge
    python_abi                          3.8           3_cp38               conda-forge
    pytz                                2022.6        pyhd8ed1ab_0         conda-forge
    pyu2f                               0.1.5         pyhd8ed1ab_0         conda-forge
    pyxlsb                              1.0.10        pyhd8ed1ab_0         conda-forge
    pyyaml                              6.0           py38h0a891b7_5       conda-forge
    qt-main                             5.15.6        h7acdfc8_2           conda-forge
    re2                                 2022.06.01    h27087fc_1           conda-forge
    readline                            8.1.2         h0f457ee_0           conda-forge
    requests                            2.28.1        pyhd8ed1ab_1         conda-forge
    requests-oauthlib                   1.3.1         pyhd8ed1ab_0         conda-forge
    rsa                                 4.9           pyhd8ed1ab_0         conda-forge
    rtree                               1.0.1         py38h02d302b_1       conda-forge
    s2n                                 1.0.10        h9b69904_0           conda-forge
    s3fs                                2022.11.0     pyhd8ed1ab_0         conda-forge
    s3transfer                          0.6.0         pyhd8ed1ab_0         conda-forge
    scikit-learn                        1.2.0         py38h1e1a916_0       conda-forge
    scipy                               1.9.3         py38h8ce737c_2       conda-forge
    setuptools                          65.5.1        pyhd8ed1ab_0         conda-forge
    shapely                             1.8.5         py38hafd38ec_2       conda-forge
    sip                                 6.7.5         py38hfa26641_0       conda-forge
    six                                 1.16.0        pyh6c4a22f_0         conda-forge
    snappy                              1.1.9         hbd366e4_2           conda-forge
    sortedcontainers                    2.4.0         pyhd8ed1ab_0         conda-forge
    soupsieve                           2.3.2.post1   pyhd8ed1ab_0         conda-forge
    sqlalchemy                          1.4.45        py38h1de0b5d_0       conda-forge
    sqlite                              3.40.0        h4ff8645_0           conda-forge
    stack_data                          0.6.2         pyhd8ed1ab_0         conda-forge
    tabulate                            0.9.0         pyhd8ed1ab_1         conda-forge
    threadpoolctl                       3.1.0         pyh8a188c0_0         conda-forge
    tiledb                              2.11.3        h1e4a385_1           conda-forge
    tk                                  8.6.12        h27826a3_0           conda-forge
    toml                                0.10.2        pyhd8ed1ab_0         conda-forge
    tomli                               2.0.1         pyhd8ed1ab_0         conda-forge
    tornado                             6.2           py38h0a891b7_1       conda-forge
    tqdm                                4.64.1        pyhd8ed1ab_0         conda-forge
    traitlets                           5.7.0         pyhd8ed1ab_0         conda-forge
    typing-extensions                   4.4.0         hd8ed1ab_0           conda-forge
    typing_extensions                   4.4.0         pyha770c72_0         conda-forge
    typing_inspect                      0.7.1         pyh6c4a22f_0         conda-forge
    tzcode                              2022g         h166bdaf_0           conda-forge
    tzdata                              2022g         h191b570_0           conda-forge
    unicodedata2                        15.0.0        py38h0a891b7_0       conda-forge
    urllib3                             1.26.13       pyhd8ed1ab_0         conda-forge
    versioneer                          0.28          pyhd8ed1ab_0         conda-forge
    wcwidth                             0.2.5         pyh9f0ad1d_2         conda-forge
    webencodings                        0.5.1         py_1                 conda-forge
    wheel                               0.38.4        pyhd8ed1ab_0         conda-forge
    wrapt                               1.14.1        py38h0a891b7_1       conda-forge
    xarray                              2022.12.0     pyhd8ed1ab_0         conda-forge
    xcb-util                            0.4.0         h166bdaf_0           conda-forge
    xcb-util-image                      0.4.0         h166bdaf_0           conda-forge
    xcb-util-keysyms                    0.4.0         h166bdaf_0           conda-forge
    xcb-util-renderutil                 0.3.9         h166bdaf_0           conda-forge
    xcb-util-wm                         0.4.1         h166bdaf_0           conda-forge
    xerces-c                            3.2.4         h55805fa_1           conda-forge
    xlrd                                2.0.1         pyhd8ed1ab_3         conda-forge
    xlsxwriter                          3.0.3         pyhd8ed1ab_0         conda-forge
    xorg-kbproto                        1.0.7         h7f98852_1002        conda-forge
    xorg-libice                         1.0.10        h7f98852_0           conda-forge
    xorg-libsm                          1.2.3         hd9c2040_1000        conda-forge
    xorg-libx11                         1.7.2         h7f98852_0           conda-forge
    xorg-libxau                         1.0.9         h7f98852_0           conda-forge
    xorg-libxdmcp                       1.1.3         h7f98852_0           conda-forge
    xorg-libxext                        1.3.4         h7f98852_1           conda-forge
    xorg-libxrender                     0.9.10        h7f98852_1003        conda-forge
    xorg-renderproto                    0.11.1        h7f98852_1002        conda-forge
    xorg-xextproto                      7.3.0         h7f98852_1002        conda-forge
    xorg-xproto                         7.0.31        h7f98852_1007        conda-forge
    xyzservices                         2022.9.0      pyhd8ed1ab_0         conda-forge
    xz                                  5.2.6         h166bdaf_0           conda-forge
    yaml                                0.2.5         h7f98852_2           conda-forge
    yarl                                1.8.1         py38h0a891b7_0       conda-forge
    zipp                                3.11.0        pyhd8ed1ab_0         conda-forge
    zlib                                1.2.13        h166bdaf_4           conda-forge
    zstandard                           0.19.0        py38h5945529_1       conda-forge
    zstd                                1.5.2         h6239696_4           conda-forge
Warning: The `save-state` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
@rebecca-palmer rebecca-palmer added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Dec 11, 2022
@phofl
Copy link
Member

phofl commented Dec 12, 2022

Can we add this easily?

@phofl phofl added the Testing pandas testing functions or related to the test suite label Dec 12, 2022
@jbrockmendel
Copy link
Member

My understanding of atol/rtol is that they are really only intended for float data. i am skeptical of extending that to datetime scalars

@rebecca-palmer
Copy link
Contributor Author

rtol possibly doesn't make sense on datetimes because of the arbitrary zero point. atol on datetimes, and both of them on timedeltas, do make sense but may or may not be worth the effort.

I'm not sure if having them explicitly raise NotImplementedError would be helpful, or if that would mostly just break use of assert_almost_equal on mixed-dtype DataFrames containing datetimes that match exactly and numbers that match only approximately.

Maybe just add something along the lines of "atol/rtol ignored - only exact matching implemented for this dtype" (could probably use better wording) to the failure message?

@MarcoGorelli
Copy link
Member

Agree on raising here, or documenting that non-exact equality is only applicable to floats (relevant issue: #55882)

@mroeschke mroeschke added Error Reporting Incorrect or improved errors from pandas and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 16, 2024
@mroeschke mroeschke changed the title BUG: _testing.assert_almost_equal on datetimes actually checks exact equality ENH: _testing.assert_almost_equal on datetimes actually checks exact equality Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas Testing pandas testing functions or related to the test suite
Projects
None yet
Development

No branches or pull requests

5 participants