Skip to content

Commit

Permalink
Merge pull request #529 from BioGeek/docs-fix
Browse files Browse the repository at this point in the history
Typo fixes and documentation fix
  • Loading branch information
neutrinoceros authored Oct 25, 2024
2 parents 233d800 + eeb1632 commit 55f1ac4
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 55 deletions.
74 changes: 40 additions & 34 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,45 @@ ci:
autoupdate_schedule: monthly

exclude: "^(\
paper/.*.py\
)"
paper/.*.py\
)"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: no-commit-to-branch
- id: check-shebang-scripts-are-executable
- id: check-executables-have-shebangs
- id: check-yaml
- id: check-toml

- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black

- repo: https://github.com/adamchainz/blacken-docs
rev: 1.18.0
hooks:
- id: blacken-docs
additional_dependencies: [black==24.1.1]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: ruff
args: [--fix, --show-fixes]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: rst-backticks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: no-commit-to-branch
- id: check-shebang-scripts-are-executable
- id: check-executables-have-shebangs
- id: check-yaml
- id: check-toml

- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black

- repo: https://github.com/adamchainz/blacken-docs
rev: 1.19.1
hooks:
- id: blacken-docs
additional_dependencies: [black==24.1.1]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1
hooks:
- id: ruff
args: [--fix, --show-fixes]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: rst-backticks

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
args: [--skip="*.pdf", -L, 'smoot,copin,celcius,ue,bu,dne,ond']
4 changes: 2 additions & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ tests will fail with errors about missing python executables.

This guide makes use of ``pyenv`` to set up all of the Python versions used in
the unyt test suite. You do not have to use ``pyenv`` if you have other ways of
managing your python evironment using your operating system's package manager or
managing your python environment using your operating system's package manager or
``conda``.

1. Fork the ``unyt`` repo on GitHub.
Expand Down Expand Up @@ -143,7 +143,7 @@ We use the ``pytest`` test runner as well as the ``tox`` test wrapper to manage
running tests on various versions of python.

To run the tests on your copy of the ``unyt`` repository using your current
python evironment, run ``pytest`` in the root of the repository using the
python environment, run ``pytest`` in the root of the repository using the
following arguments::

$ cd unyt/
Expand Down
4 changes: 2 additions & 2 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ This release includes a few minor new features and bugfixes for the 2.0.0 releas
bugfixes. There are some small backwards incompatible changes in this release
related to automatic unit simplification and handling of dtypes. Please see the
release notes below for more details. If you are upgrading from ``unyt 1.x`` we
suggest testing to make sure these changes do not siginificantly impact you. If
suggest testing to make sure these changes do not significantly impact you. If
you run into issues please let us know by `opening an issue on GitHub
<https://github.com/yt-project/unyt/issues/new>`_.

Expand Down Expand Up @@ -703,7 +703,7 @@ DougAJ4, Ma Jianjun, Paul Ivanov, and Stephan Hoyer for reporting issues.
``unyt``. See `PR #21 <https://github.com/yt-project/unyt/pull/21>`_.
* Made adjustments to the rules for converting between CGS and MKS E&M units so
that errors are only raised when going between unit systems and not merely
when doing a complicated unit conversion invoving E&M units. See `PR #20
when doing a complicated unit conversion involving E&M units. See `PR #20
<https://github.com/yt-project/unyt/pull/20>`_.
* ``round(q)`` where ``q`` is a ``unyt_quantity`` instance will no
longer raise an error and will now return the nearest rounded float.
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Running the tests
-----------------

You can check that :mod:`unyt` is working properly by running the unit tests
on your intalled copy:
on your installed copy:

.. doctest::

Expand Down
6 changes: 3 additions & 3 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ we can look up from `Wikipedia
Let's break up this example into a few components so you can see what's going
on. First, we import the unit symbols we need from the :mod:`unyt` namespace::

>>> from unyt import Mjup, G, km
>>> from unyt import Mjup, G, AU

The :mod:`unyt` namespace has a large number of units and physical constants you
can import to apply units to data in your own code. You can see how that works
Expand All @@ -81,7 +81,7 @@ in the example::
>>> semimajor_axis
unyt_array([0.002819 , 0.0044856 , 0.00715526, 0.01258513], 'AU')

By multiplying by ``km``, we converted the Python list into a
By multiplying by ``AU``, we converted the Python list into a
:class:`unyt.unyt_array <unyt.array.unyt_array>` instance. This is a class
that's built into :mod:`unyt`, has units attached to it, and knows how to
convert itself into different dimensionally equivalent units::
Expand Down Expand Up @@ -1128,7 +1128,7 @@ data are stored internally in :mod:`unyt` in MKS units.
You can also use two helper functions provided by :mod:`unyt`,
:func:`unyt.unit_systems.add_constants` and
:func:`unyt.unit_systems.add_symbols`, to populate a namespace with a set of
predefined unit symbols or physical consants. This namespace could correspond to
predefined unit symbols or physical constants. This namespace could correspond to
the names importable from a module or the names of attributes of an object, or
any other generic dictionary.

Expand Down
2 changes: 1 addition & 1 deletion paper/paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ they are working with, which may be beneficial in some cases, however it also
means that users have a bit of extra cognitive overhead they need to deal with
every time they use `Pint`.

![A benchmark comparing the ratio of the time to apply units to lists and NumPy `ndarray` instances to the time to interpret the same list or `ndarray` to an `ndarray`. This ratio, $T_{\rm package}/T_{\rm numpy}$, corresponds to the overhead of converting data to work with one of the three packages. Values close to unity correspond to zero or negligible overhead, while values larger than unity correspond to measureable overhead. Optimally all values would be near unity. In practice, applying units to small arrays incurs substantial overhead. Each test is shown for three different sizes of input data, including inputs with size 3, 1,000, and 1,000,000. The black lines at the top of the bars indicate the sample standard deviation. The $T_{\rm numpy}$ time is calculated by benchmarking the time to perform `np.asarray(data)` where `data` is either a `list` or an `ndarray`.](apply.png)
![A benchmark comparing the ratio of the time to apply units to lists and NumPy `ndarray` instances to the time to interpret the same list or `ndarray` to an `ndarray`. This ratio, $T_{\rm package}/T_{\rm numpy}$, corresponds to the overhead of converting data to work with one of the three packages. Values close to unity correspond to zero or negligible overhead, while values larger than unity correspond to measurable overhead. Optimally all values would be near unity. In practice, applying units to small arrays incurs substantial overhead. Each test is shown for three different sizes of input data, including inputs with size 3, 1,000, and 1,000,000. The black lines at the top of the bars indicate the sample standard deviation. The $T_{\rm numpy}$ time is calculated by benchmarking the time to perform `np.asarray(data)` where `data` is either a `list` or an `ndarray`.](apply.png)

In addition, the `Quantity` class provided by `Pint` is not a subclass of
NumPy's `ndarray`. Instead, it is a wrapper around an internal `ndarray`
Expand Down
2 changes: 1 addition & 1 deletion unyt/_array_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
np.busday_offset,
np.is_busday,
# not clear how to approach
np.piecewise, # astropy.units doens't have a simple implementation either
np.piecewise, # astropy.units doesn't have a simple implementation either
np.packbits,
np.unpackbits,
np.ix_,
Expand Down
4 changes: 2 additions & 2 deletions unyt/_mpl_array_converter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def axisinfo(unit, axis):
unit : Unit object, string, or tuple
This parameter comes from unyt_arrayConverter.default_units() or from
user code such as Axes.plot(), Axis.set_units(), etc. In user code, it
is possible to convert the plotted units by specifing the new unit as
is possible to convert the plotted units by specifying the new unit as
a string, such as "ms", or as a tuple, such as ("J", "thermal")
following the call signature of unyt_array.convert_to_units().
axis : Axis object
Expand Down Expand Up @@ -107,7 +107,7 @@ def convert(value, unit, axis):
unit : Unit, string or tuple
This parameter comes from unyt_arrayConverter.default_units() or from
user code such as Axes.plot(), Axis.set_units(), etc. In user code, it
is possible to convert the plotted units by specifing the new unit as
is possible to convert the plotted units by specifying the new unit as
a string, such as "ms", or as a tuple, such as ("J", "thermal")
following the call signature of unyt_array.convert_to_units().
axis : Axis object
Expand Down
2 changes: 1 addition & 1 deletion unyt/_on_demand_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def __init__(self, pkg_name, exc=None):
exc.add_note(error_note)
self.error = exc
else:
# mimick Python 3.11 behaviour:
# mimic Python 3.11 behaviour:
# preserve error message and traceback
self.error = type(exc)(f"{exc!s}\n{error_note}").with_traceback(
exc.__traceback__
Expand Down
2 changes: 1 addition & 1 deletion unyt/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ def to(self, units, equivalence=None, **kwargs):
quantity, try the :meth:`list_equivalencies`
method. Default: None
kwargs: optional
Any additional keywoard arguments are supplied to the
Any additional keyword arguments are supplied to the
equivalence
Raises
Expand Down
4 changes: 2 additions & 2 deletions unyt/equivalencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class NumberDensityEquivalence(Equivalence):
Parameters
----------
mu : float
The mean molecular weight. Defaults to 0.6 whcih is valid for fully
The mean molecular weight. Defaults to 0.6 which is valid for fully
ionized gas with primordial composition.
Example
Expand Down Expand Up @@ -455,7 +455,7 @@ def __str__(self):


class EffectiveTemperatureEquivalence(Equivalence):
"""Equivalence between the emmitted flux accross all wavelengths and
"""Equivalence between the emitted flux across all wavelengths and
temperature of a blackbody
For a blackbody emitter with Temperature :math:`T` emitting radiation with
Expand Down
4 changes: 2 additions & 2 deletions unyt/tests/test_array_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# this is a subset of NOT_HANDLED_FUNCTIONS for which there's nothing to do
# because they don't apply to (real) numeric types
# or they work as expected out of the box
# This is not necessarilly complete !
# This is not necessarily complete !
NOOP_FUNCTIONS = {
np.all, # expects booleans
np.amax, # works out of the box (tested)
Expand Down Expand Up @@ -383,7 +383,7 @@ def test_dot_matrices(out):
assert isinstance(out, np.ndarray)

if isinstance(out, unyt_array):
# check that the result can be converted to predictible units
# check that the result can be converted to predictable units
res.in_units("cm * s")
assert out.units == res.units

Expand Down
2 changes: 1 addition & 1 deletion unyt/tests/test_unyt_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,7 @@ def test_equivalencies():
assert T.units == u.m.units / u.s.units
assert c_s.units == u.km.units / u.s.units

# tempearture <-> energy
# temperature <-> energy

mu = 0.5
gg = 4.0 / 3.0
Expand Down
4 changes: 2 additions & 2 deletions unyt/unit_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def add(
offset : float, optional
If set, the zero-point offset to apply to the unit to convert
to SI. This is mostly used for units like Farhenheit and
Celcius that are not defined on an absolute scale.
Celsius that are not defined on an absolute scale.
prefixable : bool
If True, then SI-prefix versions of the unit will be created
along with the unit itself.
Expand Down Expand Up @@ -249,7 +249,7 @@ def from_json(cls, json_text):
----------
json_text : str
A string containing a json represention of a UnitRegistry
A string containing a json representation of a UnitRegistry
"""
data = json.loads(json_text)
lut = _correct_old_unit_registry(data, sympify=True)
Expand Down

0 comments on commit 55f1ac4

Please sign in to comment.