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

Type error issue when using this package with Pytest #22

Closed
xenolex opened this issue Jul 20, 2023 · 1 comment
Closed

Type error issue when using this package with Pytest #22

xenolex opened this issue Jul 20, 2023 · 1 comment

Comments

@xenolex
Copy link

xenolex commented Jul 20, 2023

https://github.com/Jingnan-Jia/segmentation_metrics/blob/5387ddb07c31f65c0617ecb6ae88f8170cc305fa/seg_metrics/seg_metrics.py#L213C9-L213C66

There is a Type error issue when using this package with Pytest:

venv/lib/python3.10/site-packages/seg_metrics/seg_metrics.py:355: in write_metrics
metrics_dict_all_labels = get_metrics_dict_all_labels(labels, gdth, pred, spacing=gdth_spacing[::-1],
venv/lib/python3.10/site-packages/seg_metrics/seg_metrics.py:213: in get_metrics_dict_all_labels
logging.info('\nstart to get metrics for label: ', label)
/usr/local/lib/python3.10/logging/init.py:2138: in info
root.info(msg, *args, **kwargs)
/usr/local/lib/python3.10/logging/init.py:1477: in info
self._log(INFO, msg, args, **kwargs)
/usr/local/lib/python3.10/logging/init.py:1624: in _log
self.handle(record)
/usr/local/lib/python3.10/logging/init.py:1634: in handle
self.callHandlers(record)
/usr/local/lib/python3.10/logging/init.py:1696: in callHandlers
hdlr.handle(record)
/usr/local/lib/python3.10/logging/init.py:968: in handle
self.emit(record)
/usr/local/lib/python3.10/site-packages/_pytest/logging.py:342: in emit
super().emit(record)
/usr/local/lib/python3.10/logging/init.py:1108: in emit
self.handleError(record)
/usr/local/lib/python3.10/logging/init.py:1100: in emit
msg = self.format(record)
/usr/local/lib/python3.10/logging/init.py:943: in format
return fmt.format(record)
/usr/local/lib/python3.10/site-packages/_pytest/logging.py:113: in format
return super().format(record)
/usr/local/lib/python3.10/logging/init.py:678: in format
record.message = record.getMessage()

def getMessage(self):
    """
    Return the message for this LogRecord.

    Return the message for this LogRecord after merging any user-supplied
    arguments with the message.
    """
    msg = str(self.msg)
    if self.args:
      msg = msg % self.args

E TypeError: not all arguments converted during string formatting

The fix is to change this line to:
logging.info(f'\nstart to get metrics for label: {label}')

@Jingnan-Jia
Copy link
Owner

Thanks for this issue, I have fixed it.

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

No branches or pull requests

2 participants