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

Test failures in seaborn project #315

Open
kgilpin opened this issue May 24, 2024 · 0 comments
Open

Test failures in seaborn project #315

kgilpin opened this issue May 24, 2024 · 0 comments
Labels
bug Something isn't working investigate needs further investigation

Comments

@kgilpin
Copy link
Contributor

kgilpin commented May 24, 2024

Running tests with appmap enabled:


============================================================== FAILURES ==============================================================
________________________________________________ TestHeatmap.test_mask_input[object] _________________________________________________

fill_value = array('?', dtype='<U1'), ndtype = dtype('float64')

    def _check_fill_value(fill_value, ndtype):
        """
        Private function validating the given `fill_value` for the given dtype.
    
        If fill_value is None, it is set to the default corresponding to the dtype.
    
        If fill_value is not None, its value is forced to the given dtype.
    
        The result is always a 0d array.
    
        """
        ndtype = np.dtype(ndtype)
        if fill_value is None:
            fill_value = default_fill_value(ndtype)
        elif ndtype.names is not None:
            if isinstance(fill_value, (ndarray, np.void)):
                try:
                    fill_value = np.array(fill_value, copy=False, dtype=ndtype)
                except ValueError as e:
                    err_msg = "Unable to transform %s to dtype %s"
                    raise ValueError(err_msg % (fill_value, ndtype)) from e
            else:
                fill_value = np.asarray(fill_value, dtype=object)
                fill_value = np.array(_recursive_set_fill_value(fill_value, ndtype),
                                      dtype=ndtype)
        else:
            if isinstance(fill_value, str) and (ndtype.char not in 'OSVU'):
                # Note this check doesn't work if fill_value is not a scalar
                err_msg = "Cannot set fill value of string with array of dtype %s"
                raise TypeError(err_msg % ndtype)
            else:
                # In case we want to convert 1e20 to int.
                # Also in case of converting string arrays.
                try:
>                   fill_value = np.array(fill_value, copy=False, dtype=ndtype)
E                   ValueError: could not convert string to float: '?'

venv/lib/python3.12/site-packages/numpy/ma/core.py:467: ValueError

The above exception was the direct cause of the following exception:

self = <tests.test_matrix.TestHeatmap object at 0x1552b99a0>, dtype = <class 'object'>

    @pytest.mark.parametrize("dtype", [float, np.int64, object])
    def test_mask_input(self, dtype):
        kws = self.default_kws.copy()
    
        mask = self.x_norm > 0
        kws['mask'] = mask
        data = self.x_norm.astype(dtype)
>       p = mat._HeatMapper(data, **kws)

tests/test_matrix.py:98: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
seaborn/matrix.py:163: in __init__
    self._determine_cmap_params(plot_data, vmin, vmax,
venv/lib/python3.12/site-packages/_appmap/wrapt/wrappers.py:712: in __call__
    return self._self_wrapper(self.__wrapped__, self._self_instance,
venv/lib/python3.12/site-packages/_appmap/instrument.py:129: in instrumented_fn
    return call_instrumented(f, instance, args, kwargs)
venv/lib/python3.12/site-packages/_appmap/instrument.py:92: in call_instrumented
    ret = f.fn(*args, **kwargs)
seaborn/matrix.py:197: in _determine_cmap_params
    calc_data = plot_data.astype(float).filled(np.nan)
venv/lib/python3.12/site-packages/numpy/ma/core.py:3066: in __array_finalize__
    self._fill_value = _check_fill_value(self._fill_value, self.dtype)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

fill_value = array('?', dtype='<U1'), ndtype = dtype('float64')

    def _check_fill_value(fill_value, ndtype):
        """
        Private function validating the given `fill_value` for the given dtype.
    
        If fill_value is None, it is set to the default corresponding to the dtype.
    
        If fill_value is not None, its value is forced to the given dtype.
    
        The result is always a 0d array.
    
        """
        ndtype = np.dtype(ndtype)
        if fill_value is None:
            fill_value = default_fill_value(ndtype)
        elif ndtype.names is not None:
            if isinstance(fill_value, (ndarray, np.void)):
                try:
                    fill_value = np.array(fill_value, copy=False, dtype=ndtype)
                except ValueError as e:
                    err_msg = "Unable to transform %s to dtype %s"
                    raise ValueError(err_msg % (fill_value, ndtype)) from e
            else:
                fill_value = np.asarray(fill_value, dtype=object)
                fill_value = np.array(_recursive_set_fill_value(fill_value, ndtype),
                                      dtype=ndtype)
        else:
            if isinstance(fill_value, str) and (ndtype.char not in 'OSVU'):
                # Note this check doesn't work if fill_value is not a scalar
                err_msg = "Cannot set fill value of string with array of dtype %s"
                raise TypeError(err_msg % ndtype)
            else:
                # In case we want to convert 1e20 to int.
                # Also in case of converting string arrays.
                try:
                    fill_value = np.array(fill_value, copy=False, dtype=ndtype)
                except (OverflowError, ValueError) as e:
                    # Raise TypeError instead of OverflowError or ValueError.
                    # OverflowError is seldom used, and the real problem here is
                    # that the passed fill_value is not compatible with the ndtype.
                    err_msg = "Cannot convert fill_value %s to dtype %s"
>                   raise TypeError(err_msg % (fill_value, ndtype)) from e
E                   TypeError: Cannot convert fill_value ? to dtype float64

venv/lib/python3.12/site-packages/numpy/ma/core.py:473: TypeError
--------------------------------------------------------- Captured log call ----------------------------------------------------------
INFO     _appmap.recording:recording.py:77 writing /Users/kgilpin/source/land-of-apps/seaborn/tmp/appmap/pytest/tests_test_matrix_TestHeatmap_test_mask_input_object.appmap.json
_________________________________________________________ test_load_datasets _________________________________________________________

self = <urllib.request.HTTPSHandler object at 0x44d8bac00>, http_class = <class 'http.client.HTTPSConnection'>
req = <urllib.request.Request object at 0x49bc70ec0>, http_conn_args = {'context': <ssl.SSLContext object at 0x44d805d50>}
host = 'raw.githubusercontent.com', h = <http.client.HTTPSConnection object at 0x49bc9d5b0>
headers = {'Connection': 'close', 'Host': 'raw.githubusercontent.com', 'User-Agent': 'Python-urllib/3.12'}

    def do_open(self, http_class, req, **http_conn_args):
        """Return an HTTPResponse object for the request, using http_class.
    
        http_class must implement the HTTPConnection API from http.client.
        """
        host = req.host
        if not host:
            raise URLError('no host given')
    
        # will parse host:port
        h = http_class(host, timeout=req.timeout, **http_conn_args)
        h.set_debuglevel(self._debuglevel)
    
        headers = dict(req.unredirected_hdrs)
        headers.update({k: v for k, v in req.headers.items()
                        if k not in headers})
    
        # TODO(jhylton): Should this be redesigned to handle
        # persistent connections?
    
        # We want to make an HTTP/1.1 request, but the addinfourl
        # class isn't prepared to deal with a persistent connection.
        # It will try to read all remaining data from the socket,
        # which will block while the server waits for the next request.
        # So make sure the connection gets closed after the (only)
        # request.
        headers["Connection"] = "close"
        headers = {name.title(): val for name, val in headers.items()}
    
        if req._tunnel_host:
            tunnel_headers = {}
            proxy_auth_hdr = "Proxy-Authorization"
            if proxy_auth_hdr in headers:
                tunnel_headers[proxy_auth_hdr] = headers[proxy_auth_hdr]
                # Proxy-Authorization should not be sent to origin
                # server.
                del headers[proxy_auth_hdr]
            h.set_tunnel(req._tunnel_host, headers=tunnel_headers)
    
        try:
            try:
>               h.request(req.get_method(), req.selector, req.data, headers,
                          encode_chunked=req.has_header('Transfer-encoding'))

/opt/miniconda3/lib/python3.12/urllib/request.py:1344: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
venv/lib/python3.12/site-packages/_appmap/wrapt/wrappers.py:712: in __call__
    return self._self_wrapper(self.__wrapped__, self._self_instance,
venv/lib/python3.12/site-packages/_appmap/instrument.py:129: in instrumented_fn
    return call_instrumented(f, instance, args, kwargs)
venv/lib/python3.12/site-packages/_appmap/instrument.py:92: in call_instrumented
    ret = f.fn(*args, **kwargs)
/opt/miniconda3/lib/python3.12/http/client.py:1327: in request
    self._send_request(method, url, body, headers, encode_chunked)
/opt/miniconda3/lib/python3.12/http/client.py:1373: in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
/opt/miniconda3/lib/python3.12/http/client.py:1322: in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
/opt/miniconda3/lib/python3.12/http/client.py:1081: in _send_output
    self.send(msg)
/opt/miniconda3/lib/python3.12/http/client.py:1025: in send
    self.connect()
/opt/miniconda3/lib/python3.12/http/client.py:1468: in connect
    self.sock = self._context.wrap_socket(self.sock,
/opt/miniconda3/lib/python3.12/ssl.py:455: in wrap_socket
    return self.sslsocket_class._create(
/opt/miniconda3/lib/python3.12/ssl.py:1046: in _create
    self.do_handshake()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <ssl.SSLSocket [closed] fd=-1, family=2, type=1, proto=0>, block = False

    @_sslcopydoc
    def do_handshake(self, block=False):
        self._check_connected()
        timeout = self.gettimeout()
        try:
            if timeout == 0.0 and block:
                self.settimeout(None)
>           self._sslobj.do_handshake()
E           ConnectionResetError: [Errno 54] Connection reset by peer

/opt/miniconda3/lib/python3.12/ssl.py:1321: ConnectionResetError

During handling of the above exception, another exception occurred:

args = (), kwargs = {}, f = <http.client.HTTPResponse object at 0x49ba0cd60>

    def wrapper(*args, **kwargs):
        # attempt to connect
        try:
            f = urlopen(url)
        except (OSError, HTTPException):
            pytest.skip("No internet connection")
        else:
            f.close()
>           return t(*args, **kwargs)

tests/test_utils.py:62: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_utils.py:486: in test_load_datasets
    check_load_dataset(name)
tests/test_utils.py:456: in check_load_dataset
    ds = load_dataset(name, cache=False)
venv/lib/python3.12/site-packages/_appmap/wrapt/wrappers.py:622: in __call__
    return self._self_wrapper(self.__wrapped__, self._self_instance,
venv/lib/python3.12/site-packages/_appmap/instrument.py:129: in instrumented_fn
    return call_instrumented(f, instance, args, kwargs)
venv/lib/python3.12/site-packages/_appmap/instrument.py:92: in call_instrumented
    ret = f.fn(*args, **kwargs)
seaborn/utils.py:579: in load_dataset
    df = pd.read_csv(full_path, **kws)
venv/lib/python3.12/site-packages/pandas/io/parsers/readers.py:1026: in read_csv
    return _read(filepath_or_buffer, kwds)
venv/lib/python3.12/site-packages/pandas/io/parsers/readers.py:620: in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
venv/lib/python3.12/site-packages/pandas/io/parsers/readers.py:1620: in __init__
    self._engine = self._make_engine(f, self.engine)
venv/lib/python3.12/site-packages/pandas/io/parsers/readers.py:1880: in _make_engine
    self.handles = get_handle(
venv/lib/python3.12/site-packages/pandas/io/common.py:728: in get_handle
    ioargs = _get_filepath_or_buffer(
venv/lib/python3.12/site-packages/pandas/io/common.py:384: in _get_filepath_or_buffer
    with urlopen(req_info) as req:
venv/lib/python3.12/site-packages/pandas/io/common.py:289: in urlopen
    return urllib.request.urlopen(*args, **kwargs)
/opt/miniconda3/lib/python3.12/urllib/request.py:215: in urlopen
    return opener.open(url, data, timeout)
/opt/miniconda3/lib/python3.12/urllib/request.py:515: in open
    response = self._open(req, data)
/opt/miniconda3/lib/python3.12/urllib/request.py:532: in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
/opt/miniconda3/lib/python3.12/urllib/request.py:492: in _call_chain
    result = func(*args)
/opt/miniconda3/lib/python3.12/urllib/request.py:1392: in https_open
    return self.do_open(http.client.HTTPSConnection, req,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <urllib.request.HTTPSHandler object at 0x44d8bac00>, http_class = <class 'http.client.HTTPSConnection'>
req = <urllib.request.Request object at 0x49bc70ec0>, http_conn_args = {'context': <ssl.SSLContext object at 0x44d805d50>}
host = 'raw.githubusercontent.com', h = <http.client.HTTPSConnection object at 0x49bc9d5b0>
headers = {'Connection': 'close', 'Host': 'raw.githubusercontent.com', 'User-Agent': 'Python-urllib/3.12'}

    def do_open(self, http_class, req, **http_conn_args):
        """Return an HTTPResponse object for the request, using http_class.
    
        http_class must implement the HTTPConnection API from http.client.
        """
        host = req.host
        if not host:
            raise URLError('no host given')
    
        # will parse host:port
        h = http_class(host, timeout=req.timeout, **http_conn_args)
        h.set_debuglevel(self._debuglevel)
    
        headers = dict(req.unredirected_hdrs)
        headers.update({k: v for k, v in req.headers.items()
                        if k not in headers})
    
        # TODO(jhylton): Should this be redesigned to handle
        # persistent connections?
    
        # We want to make an HTTP/1.1 request, but the addinfourl
        # class isn't prepared to deal with a persistent connection.
        # It will try to read all remaining data from the socket,
        # which will block while the server waits for the next request.
        # So make sure the connection gets closed after the (only)
        # request.
        headers["Connection"] = "close"
        headers = {name.title(): val for name, val in headers.items()}
    
        if req._tunnel_host:
            tunnel_headers = {}
            proxy_auth_hdr = "Proxy-Authorization"
            if proxy_auth_hdr in headers:
                tunnel_headers[proxy_auth_hdr] = headers[proxy_auth_hdr]
                # Proxy-Authorization should not be sent to origin
                # server.
                del headers[proxy_auth_hdr]
            h.set_tunnel(req._tunnel_host, headers=tunnel_headers)
    
        try:
            try:
                h.request(req.get_method(), req.selector, req.data, headers,
                          encode_chunked=req.has_header('Transfer-encoding'))
            except OSError as err: # timeout error
>               raise URLError(err)
E               urllib.error.URLError: <urlopen error [Errno 54] Connection reset by peer>

/opt/miniconda3/lib/python3.12/urllib/request.py:1347: URLError
--------------------------------------------------------- Captured log call ----------------------------------------------------------
INFO     _appmap.recording:recording.py:77 writing /Users/kgilpin/source/land-of-apps/seaborn/tmp/appmap/pytest/test_load_datasets.appmap.json
========================================================== warnings summary ==========================================================
venv/lib/python3.12/site-packages/_pytest/config/__init__.py:1285
  /Users/kgilpin/source/land-of-apps/seaborn/venv/lib/python3.12/site-packages/_pytest/config/__init__.py:1285: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: _appmap
    self._mark_plugins_for_rewrite(hook)

venv/lib/python3.12/site-packages/_pytest/config/__init__.py:1285
  /Users/kgilpin/source/land-of-apps/seaborn/venv/lib/python3.12/site-packages/_pytest/config/__init__.py:1285: PytestAssertRewriteWarning: Module already imported so cannot be rewritten: appmap
    self._mark_plugins_for_rewrite(hook)

tests/test_base.py:1337
  /Users/kgilpin/source/land-of-apps/seaborn/tests/test_base.py:1337: PytestRemovedIn9Warning: Marks applied to fixtures have no effect
  See docs: https://docs.pytest.org/en/stable/deprecations.html#applying-a-mark-to-a-fixture-function
    @pytest.fixture(

tests/test_base.py::TestSizeMapping::test_array_palette_deprecation
  /Users/kgilpin/source/land-of-apps/seaborn/venv/lib/python3.12/site-packages/_appmap/instrument.py:92: UserWarning: 
  The palette list has fewer values (2) than needed (3) and will cycle, which may produce an uninterpretable plot.
    ret = f.fn(*args, **kwargs)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
====================================================== short test summary info =======================================================
FAILED tests/test_matrix.py::TestHeatmap::test_mask_input[object] - TypeError: Cannot convert fill_value ? to dtype float64
FAILED tests/test_utils.py::test_load_datasets - urllib.error.URLError: <urlopen error [Errno 54] Connection reset by peer>
=========================== 2 failed, 2304 passed, 69 skipped, 6 xfailed, 4 warnings in 543.84s (0:09:03) ============================
@kgilpin kgilpin added the bug Something isn't working label May 24, 2024
@apotterri apotterri added the investigate needs further investigation label Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working investigate needs further investigation
Projects
None yet
Development

No branches or pull requests

2 participants