Skip to content

Fix the error message in the _check_dtype_and_dim function #2297

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

Merged
merged 9 commits into from
Jan 8, 2023

Conversation

seisman
Copy link
Member

@seisman seisman commented Jan 4, 2023

Description of proposed changes

Fixes #

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If wrapping a new module, open a 'Wrap new GMT module' issue and submit reasonably-sized PRs.
  • If adding new functionality, add an example to docstrings or tutorials.
  • Use underscores (not hyphens) in names of Python files and directories.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash commands are:

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

@seisman seisman added maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog labels Jan 4, 2023
@seisman seisman added this to the 0.9.0 milestone Jan 4, 2023
@seisman seisman added the needs review This PR has higher priority and needs review. label Jan 4, 2023
@willschlitzer
Copy link
Contributor

Is it incorrect to refer to the "dimensions" plural for an array (assuming it is more than 1d)?

@seisman
Copy link
Member Author

seisman commented Jan 4, 2023

Is it incorrect to refer to the "dimensions" plural for an array (assuming it is more than 1d)?

I'm not sure. Perhaps "dimensions" is more general and better.

@willschlitzer willschlitzer added final review call This PR requires final review and approval from a second reviewer and removed needs review This PR has higher priority and needs review. labels Jan 4, 2023
seisman and others added 3 commits January 4, 2023 22:00
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
Copy link
Member

@yvonnefroehlich yvonnefroehlich left a comment

Choose a reason for hiding this comment

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

The change regarding the consistent usage of x-D looks good!

The change regarding the error message should be OK.

Regarding whether it is the dimension (singular) or the dimensions (plural) of an array, I am not sure 🙁. Currently it is not consistent. For me for all four occurrences in _check_dtype_and_dim singular sounds better, as ndim is one single integer value indicating the overall number of dimensions:

  • lines 680-681:
        Check that a numpy array has the given dimensions and is a valid data
        type.   # -> change to dimension (singular)
  • lines 687-688:
        ndim : int
            The desired dimension of the array.
  • lines 697-699:
        GMTCLibError
            If the array has the wrong dimensions or is an unsupported data
            type.  # -> change to dimension (singular)
  • lines 718-720:
        # check the array has the given dimension
        if array.ndim != ndim:
            raise GMTInvalidInput(f"Expected a numpy 1-D array, got {array.ndim}-D.")

Plural is used in:
create_data

  • lines 529-533:
        dim : list of 4 integers
            The dimensions of the dataset. See the documentation for the GMT C
            API function ``GMT_Create_Data`` (``src/gmt_api.c``) for the full
            range of options regarding 'dim'. If ``None``, will pass in the
            NULL pointer.

extract_region

  • lines 1489-1491:
        * wesn : 1-D array   # <- is the * needed or a typo?
            A numpy 1-D array with the west, east, south, and north dimensions
            of the current figure.  # <- maybe limits is a better word here?

@seisman
Copy link
Member Author

seisman commented Jan 5, 2023

Regarding whether it is the dimension (singular) or the dimensions (plural) of an array, I am not sure 🙁. Currently it is not consistent. For me for all four occurrences in _check_dtype_and_dim singular sounds better, as ndim is one single integer value indicating the overall number of dimensions:

The numpy documentation for np.ndarray.ndim says:

Number of array dimensions.

So I think we can follow their style.

seisman and others added 3 commits January 7, 2023 10:00
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
@seisman seisman merged commit c14067d into main Jan 8, 2023
@seisman seisman deleted the fix-check_dtype_and_dim branch January 8, 2023 01:34
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants