FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Action ruff checks by HGWright · Pull Request #416 · SciTools/python-stratify · GitHub

Action ruff checks - #416

Open
HGWright wants to merge 1 commit into
SciTools:mainfrom
HGWright:ruff-check
Open

Action ruff checks#416
HGWright wants to merge 1 commit into
SciTools:mainfrom
HGWright:ruff-check

Conversation

Copy link
Copy Markdown
Contributor

🚀 Pull Request

Description

From #277. We have been tracking the ignored checks for Ruff. This PR goes through and actions all of the applicable checks and ignores the ones we cant deal with yet, mainly around type hinting and documentation.

Part of these checks is moving from references to unittest to pytest, and from assertEqual to just regular assert statements


scitools-ci Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Templating

This PR includes changes that may be worth sharing via templating. For each file listed below, please either:

  • Action the suggestion via a pull request editing/adding the relevant file in the SciTools/.github templates/ directory. 1
  • Raise an issue against the SciTools/.github repo for the above action if you really don't have 10mins spare right now. Include an assignee, to avoid it being forgotten.
  • Dismiss the suggestion if the changes are not suitable for templating.

You will need to dismiss this review before this PR can be merged. Recommend the reviewer does this as their final action before merging, as this text will continually update as commits come in.

Templated files

The following changed files are templated:

Template candidates

The following changed files are not currently templated, but their parent directories suggest they may be good candidates for a new template to be created:

Footnotes

  1. Include this text in the PR body to avoid any notifications about applying the template changes back to the source repo!
    @scitools-templating: please no update notification on: python-stratify

trexfeathers self-assigned this Mar 19, 2026

trexfeathers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks @HGWright, some requests for you

output_array[:] = np.inf if direction > 0 else -np.inf


class TestColumnInterpolation(unittest.TestCase):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why have you done this in some places but not in others? test_bounded_vinterp.py still has some examples.

vdims = list(set(range(z_src.ndim)) - set([axis_relative]))
z_src_reshaped = np.transpose(z_src, [axis_relative] + vdims)
z_target_reshaped = np.transpose(z_target, [axis_relative] + vdims)
# vdims = list(set(range(z_src.ndim)) - set([axis_relative]))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Commented code

invert_transpose = [data_transpose.index(ind) for ind in list(range(result.ndim))]
result = result.transpose(invert_transpose)
return result
# result = result.transpose(invert_transpose)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Commented code

Comment thread index.ipynb

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It's cool that Ruff works on notebooks. It's also cool the improved pattern it found for randomness. 👍

Comment thread pyproject.toml
"T201", # print found

]
"S101", # Use of assert detected.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You needed to add this one, presumably because you've been converting the tests to use PyTest? If you, could you move this exception down to the file-specific exceptions for src/stratify/tests/*.py?



def src_data(shape=(400, 500, 100), lazy=False):
def src_data(shape=(400, 500, 100)):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'm not quite sure of the design of this module, but lazy is very much still used. Seems like Ruff made a mistake?

lazy = "lazy" in sys.argv[1:]
interp_and_extrap(shape=(500, 600, 100), lazy=lazy)

def interp_and_extrap(
shape,
lazy,
interp=stratify.INTERPOLATE_LINEAR,
extrap=stratify.EXTRAPOLATE_NEAREST,
):
z, fz = src_data(shape, lazy)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This file has a lot more unittest left in it than test_vinterp does.

  • Still inheriting from unittest.TestCase
  • Still calling unittest.main() at the bottom
  • Maybe other stuff I've missed?

I'm guessing you went this way because the tests in this file include setUp() methods, which are a unittest thing so the tests cannot run without unittest?

Anyway it's confusing to have these different states; I would prefer everything or nothing; options:

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL