Skip to content

Improve warning handling for non-positive values when apply_log = True for InterRowMSAS #670

@fealho

Description

@fealho

Error Description

Running the compute method for InterRowMSAS with non-positive values and apply_log=True generates undesirable warnings.

Steps to Reproduce

real_keys = pd.Series(['id1', 'id1', 'id1', 'id2', 'id2', 'id2'])
real_values = pd.Series([1, 1.4, 4, -1, 16, -10])
synthetic_keys = pd.Series(['id1', 'id1', 'id1', 'id2', 'id2', 'id2'])
synthetic_values = pd.Series([1, 2, -4, 8, 16, 30])

InterRowMSAS.compute(
  real_data=(real_keys, real_values),
  synthetic_data=(synthetic_keys, synthetic_values),
  apply_log=True,
)

The code above generates the following warnings:

divide by zero encountered in log
invalid value encountered in log
invalid value encountered in subtract
invalid value encountered in reduce

Expected Behavior

These warnings should be suppressed and replaced with a clearer warning message:

There are 3 non-positive values in your data, which cannot be used with log. Consider changing 'apply_log' to False for a better result.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions