Skip to content

Values <1 for rescale_flank cause assertion error when including central pixel score #161

@rikrdo89

Description

@rikrdo89

Description

When setting a value for rescale_flank in coolpuppy less than 1 (e.g. 0.25 or 0.3), an assertion error is raised in plotpup.py when the central pixel score is included. Specifically, the error is:

Traceback (most recent call last):
  File "/myhome/bin/plotpup.py", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/myhome/lib/python3.12/site-packages/coolpuppy/plotpuppy_CLI.py", line 313, in main
    pups["score"] = pups.apply(
                    ^^^^^^^^^^^
  File "/myhome/lib/python3.12/site-packages/pandas/core/frame.py", line 10374, in apply
    return op.apply().__finalize__(self, method="apply")
           ^^^^^^^^^^
  File "/myhome/lib/python3.12/site-packages/pandas/core/apply.py", line 916, in apply    return self.apply_standard()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/myhome/lib/python3.12/site-packages/pandas/core/apply.py", line 1063, in apply_standard
    results, res_index = self.apply_series_generator()
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/myhome/lib/python3.12/site-packages/pandas/core/apply.py", line 1081, in apply_series_generator
    results[i] = self.func(v, *self.args, **self.kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/myhome/lib/python3.12/site-packages/coolpuppy/lib/puputils.py", line 80, in get_score
    return get_domain_score(pup["data"], pup["rescale_flank"])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/myhome/lib/python3.12/site-packages/coolpuppy/lib/numutils.py", line 127, in get_domain_score
    assert int(c) == c
           ^^^^^^^^^^^
AssertionError

Steps to Reproduce

  1. Run coolpuppy with a fractional value for rescale_flank (e.g., rescale_flank=0.5). It should run without issues.

  2. Run plotpup.py and do not use the --no_score flag so that the central pixel score is included.

  3. Observe that plotpup.py throws the following error:

    `assert int(c) == c`
    

Expected Behavior

The tool should handle fractional rescale_flank values correctly and compute/plot the central pixel score without raising an assertion error.

Actual Behavior

Using a fractional rescale_flank value without the --no_score flag results in an assertion error in plotpup.py. The workaround is to use --no_score, which bypasses the issue but omits the central pixel score from the plot.

Additional Information

  • Environment:
    • Python version: 3.12
    • coolpuppy version: 1.1.0 (installed using conda)
    • matplotlib version: 3.8.4
    • pandas version: 2.2.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions