Skip to content
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

docs: fix spelling and common typos #617

Merged
merged 1 commit into from Jul 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/examples.yml
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/setup-python@v1
with:
python-version: '3.8'
- name: Pre-install Numpy
- name: Pre-install NumPy
run: python -m pip install -r dev-requirements.txt nbconvert ipykernel
- name: Install kernel
run: python -m ipykernel install --user --name boost-hist
Expand Down
15 changes: 11 additions & 4 deletions .pre-commit-config.yaml
Expand Up @@ -82,13 +82,20 @@ repos:
- id: check-manifest
stages: [manual]

- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
- id: codespell
args: ["-L", "hist,nd,circularly,ba"]
exclude: ^(notebooks/xarray.ipynb|notebooks/BoostHistogramHandsOn.ipynb)$

- repo: local
hooks:
- id: disallow-pybind
name: Disallow PyBind (dual caps)
- id: disallow-caps
name: Disallow improper capitalization
language: pygrep
entry: PyBind
exclude: .pre-commit.*.yaml
entry: PyBind|Numpy|Cmake|CCache|Github|PyTest
exclude: .pre-commit-config.yaml

- repo: local
hooks:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -48,7 +48,7 @@ hist.fill(
[0.1, 0.4, 0.9],
)

# Numpy array view into histogram counts, no overflow bins
# NumPy array view into histogram counts, no overflow bins
values = hist.values()

# Make a new histogram with just the second axis, summing over the first, and
Expand Down Expand Up @@ -142,7 +142,7 @@ histograms can be plotted via any compatible library, such as [mplhep][].
* `v = h[{0:b}]`: All actions can be represented by `axis:item` dictionary instead of by position (mostly useful for slicing)
* Slicing to get histogram or set array of values
* `h2 = h[a:b]`: Access a slice of a histogram, cut portions go to flow bins if present
* `h2 = h[:, ...]`: Using `:` and `...` supported just like Numpy
* `h2 = h[:, ...]`: Using `:` and `...` supported just like NumPy
* `h2 = h[::sum]`: Third item in slice is the "action"
* `h[...] = array`: Set the bin contents, either include or omit flow bins
* Special accessors
Expand Down
8 changes: 4 additions & 4 deletions docs/CHANGELOG.md
Expand Up @@ -15,7 +15,7 @@
#### Developer changes
* Test on Python 3.10 beta releases [#600][]
* Provide a CMakeLists for quick standalone Boost.Histogram C++ experiments [#591][]
* Adding logging with PyTest failure output [#575][]
* Adding logging with pytest failure output [#575][]

[#575]: https://github.com/scikit-hep/boost-histogram/pull/575
[#576]: https://github.com/scikit-hep/boost-histogram/pull/576
Expand Down Expand Up @@ -130,7 +130,7 @@ Python 2, and mostly equivalent in API to 1.0.
* Supports converting user histogram objects that provide a
`_to_boost_histogram_` method. [#483][]
* A `view=True` parameter must now be passed to get a View instead of a standard
NumPy values arrray from `to_numpy()`. [#498][]
NumPy values array from `to_numpy()`. [#498][]

#### Bug fixes

Expand Down Expand Up @@ -484,7 +484,7 @@ library. Using Boost 1.72 release.
* Properties on accumulator views now resolve correctly [#273][]
* Division of a histogram by a number is supported again [#278][]
* Setting a histogram with length one slice fixed [#279][]
* Numpy functions now work with Numpy ints in `bins=` [#282][]
* NumPy functions now work with NumPy ints in `bins=` [#282][]
* In-place addition avoids a copy [#284][]

[#273]: https://github.com/scikit-hep/boost-histogram/pull/273
Expand Down Expand Up @@ -524,7 +524,7 @@ transition existing 0.5.x code to the new API.
* `h.axes` now has the functions from axis as well. [#183][]
* `bh.project` has become `bh.sum` [#185][]
* `.reduce(...)` and the reducers in `bh.algorithm` have been removed in favor of dictionary based UHI slicing [#259][]
* `bh.numpy` module interface updates, `histogram=bh.Histogram` replaces cryptic `bh=True`, and `density=True` is now supported in Numpy mode [#256][]
* `bh.numpy` module interface updates, `histogram=bh.Histogram` replaces cryptic `bh=True`, and `density=True` is now supported in NumPy mode [#256][]
* Added `hist.copy()` [#218][] and `hist.shape` [#264][]
* Signatures are much nicer in Python 3 [#188][]
* Reprs are better, various properties like `__module__` are now set correctly [#200][]
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Expand Up @@ -43,7 +43,7 @@ virtual environment, etc. See :ref:`usage-installation` for more details. An exa
hist.fill([.3, .5, .2],
[.1, .4, .9])

# Numpy array view into histogram counts, no overflow bins
# NumPy array view into histogram counts, no overflow bins
counts = hist.view()

See :ref:`usage-quickstart` for more.
Expand Down
4 changes: 2 additions & 2 deletions docs/usage/accumulators.rst
Expand Up @@ -156,7 +156,7 @@ Views
-----

Most of the accumulators (except Sum) support a View. This is what is returned from
a histogram when ``.view()`` is requested. This is a structured Numpy ndarray, with a few small
additions to make them easier to work with. Like a Numpy recarray, you can access the fields with
a histogram when ``.view()`` is requested. This is a structured NumPy ndarray, with a few small
additions to make them easier to work with. Like a NumPy recarray, you can access the fields with
attributes; you can even access (but not set) computed attributes like ``.variance``. A view will
also return an accumulator instance if you select a single item.
2 changes: 1 addition & 1 deletion docs/usage/analyses.rst
Expand Up @@ -36,7 +36,7 @@ True ``is_valid`` selection, you can use a ``sum``:

.. code:: python3

h1 = hist[:, True, :: bh.sum]
h1 = hist[:, True, sum]

You can expand this example to any number of dimensions, boolean flags,
and categories.
2 changes: 1 addition & 1 deletion docs/usage/installation.rst
Expand Up @@ -79,7 +79,7 @@ are dictated by Boost.Histogram’s C++ requirements: gcc >= 5.5, clang >=
3.8, msvc >= 14.1. You should have a version of pip less than 2-3 years
old (10+).

Numpy is downloaded during the build (enables multithreaded builds).
NumPy is downloaded during the build (enables multithreaded builds).
Boost is not required or needed (this only depends on included
header-only dependencies).This library is under active development; you
can install directly from GitHub if you would like.
Expand Down
12 changes: 6 additions & 6 deletions docs/usage/quickstart.rst
Expand Up @@ -64,10 +64,10 @@ should give arrays, but single values work as well:
Slicing and rebinning
---------------------

You can slice into a histogram using bin coordinates
or data coordinates using ``bh.loc(v)``. You can also
rebin with ``bh.rebin(n)`` or remove an entire axis
using ``bh.sum`` as the third slice argument:
You can slice into a histogram using bin coordinates or data coordinates using
``bh.loc(v)``. You can also rebin with ``bh.rebin(n)`` or remove an entire axis
using ``sum`` (technically as the third slice argument, though it is allowed by
itself as well):

.. code:: python3

Expand All @@ -76,15 +76,15 @@ using ``bh.sum`` as the third slice argument:
bh.axis.Regular(10, 0, 1),
bh.axis.Regular(10, 0, 1),
)
mini = hist[1:5, bh.loc(0.2) : bh.loc(0.9), :: bh.sum]
mini = hist[1:5, bh.loc(0.2) : bh.loc(0.9), sum]
# Will be 4 bins x 7 bins

See :ref:`usage-indexing`.

Accessing the contents
----------------------

You can use ``hist.values()`` to get a Numpy array from any histogram. You can
You can use ``hist.values()`` to get a NumPy array from any histogram. You can
get the variances with ``hist.variances()``, though if you fill an unweighted
storage with weights, this will return None, as you no longer can compute the
variances correctly (please use a weighted storage if you need to). You can
Expand Down
4 changes: 2 additions & 2 deletions docs/usage/transforms.rst
Expand Up @@ -38,7 +38,7 @@ transformed axis, and this will be 15-90 times slower than a compiled method, li
10, 1, 4, transform=bh.axis.transform.Function(ftype(math.log), ftype(math.exp))
)

# Pure Python: Numpy (90x slower)
# Pure Python: NumPy (90x slower)
bh.axis.Regular(
10, 1, 4, transform=bh.axis.transform.Function(ftype(np.log), ftype(np.exp))
)
Expand Down Expand Up @@ -152,7 +152,7 @@ That's it.
Using Numba
^^^^^^^^^^^

The same procedure works for numba decorators. Numpy only supports functions, not builtins like ``math.log``,
The same procedure works for numba decorators. NumPy only supports functions, not builtins like ``math.log``,
so if you want to pass those, you'll need to wrap them in a lambda function or add a bit of logic to the convert
function. Here are your options:

Expand Down
4 changes: 2 additions & 2 deletions examples/simple_2d.py
Expand Up @@ -10,12 +10,12 @@
bh.axis.Regular(20, -3, 3, metadata="x"), bh.axis.Regular(20, -3, 3, metadata="y")
)

# Generate some Numpy arrays with data to fill into histogram,
# Generate some NumPy arrays with data to fill into histogram,
# in this case normal distributed random numbers in x and y
x = np.random.randn(1_000)
y = 0.5 * np.random.randn(1_000)

# Fill histogram with Numpy arrays, this is very fast
# Fill histogram with NumPy arrays, this is very fast
h.fill(x, y)

# Get numpy.histogram compatible representation of the histogram
Expand Down
4 changes: 2 additions & 2 deletions examples/simple_numpy.py
Expand Up @@ -10,15 +10,15 @@
bh.axis.Regular(10, -3, 3, metadata="x"), bh.axis.Regular(10, -3, 3, metadata="y")
)

# Generate some Numpy arrays with data to fill into histogram,
# Generate some NumPy arrays with data to fill into histogram,
# in this case normal distributed random numbers in x and y
x_data = np.random.randn(1000)
y_data = 0.5 * np.random.randn(1000)

# Fill histogram with numpy arrays, this is very fast
h.fill(x_data, y_data)

# Get representations of the bin edges as Numpy arrays
# Get representations of the bin edges as NumPy arrays
x = h.axes[0].edges
y = h.axes[1].edges

Expand Down
4 changes: 2 additions & 2 deletions include/bh_python/transform.hpp
Expand Up @@ -25,7 +25,7 @@ struct func_transform {
py::object _forward_converted; // Held for reference counting if conversion makes a
// new object (ctypes does not bump the refcount)
py::object _inverse_converted;
py::object _convert_ob; // Called before computing tranform if not None
py::object _convert_ob; // Called before computing transform if not None
py::str _name; // Optional name (uses repr from objects otherwise)

/// Convert an object into a std::function. Can handle ctypes
Expand Down Expand Up @@ -84,7 +84,7 @@ struct func_transform {
src);
}

// Note that each error is slighly different just to help with debugging
// Note that each error is slightly different just to help with debugging
throw py::type_error("Only ctypes double(double) and C++ functions allowed "
"(must be stateless)");
}
Expand Down
6 changes: 3 additions & 3 deletions notebooks/BoostHistogramHandsOn.ipynb
Expand Up @@ -231,7 +231,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2: Drop-in replacement for Numpy\n",
"## 2: Drop-in replacement for NumPy\n",
"\n",
"To start using this yourself, you don't even need to change your code. Let's try the numpy adapters."
]
Expand Down Expand Up @@ -330,7 +330,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Now we can move over to boost-histogram one step at a time! Just to be complete, we can also go back to a Numpy tuple from a Histogram object:"
"Now we can move over to boost-histogram one step at a time! Just to be complete, we can also go back to a NumPy tuple from a Histogram object:"
]
},
{
Expand Down Expand Up @@ -948,7 +948,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's try to make a density histogram like Numpy's."
"Let's try to make a density histogram like NumPy's."
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions notebooks/PerformanceComparison.ipynb
Expand Up @@ -81,7 +81,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Traditional 1D Numpy Histogram\n",
"#### Traditional 1D NumPy Histogram\n",
"\n",
"This is reasonably optimized; it should provide good perforance."
]
Expand Down Expand Up @@ -232,7 +232,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Traditional 2D Numpy histogram\n",
"#### Traditional 2D NumPy histogram\n",
"\n",
"Not as well optimized for regular filling."
]
Expand Down
2 changes: 1 addition & 1 deletion notebooks/ThreadedFills.ipynb
Expand Up @@ -136,7 +136,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This makes four seperate histograms, then fills them and adds at the end."
"This makes four separate histograms, then fills them and adds at the end."
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion notebooks/xarray.ipynb
Expand Up @@ -235,7 +235,7 @@
"### More features\n",
"\n",
"Let's add a few more features to our function defined above.\n",
"* Let's allow bins to be a list of axes or even a completly prepared histogram; this will allow us to take advantage of boost-histogram features later.\n",
"* Let's allow bins to be a list of axes or even a completely prepared histogram; this will allow us to take advantage of boost-histogram features later.\n",
"* Let's add a weights keyword so we can do weighted histograms as well."
]
},
Expand Down
4 changes: 2 additions & 2 deletions scripts/performance_report.py
Expand Up @@ -72,7 +72,7 @@ def print_timer(setup, statement, name, storage, fill, flow, base=None, n=10):
base = print_timer(
setup_1d,
"h, _ = np.histogram(vals, bins=bins, range=ranges)",
name="Numpy",
name="NumPy",
storage="uint64",
fill="",
flow="no",
Expand Down Expand Up @@ -163,7 +163,7 @@ def print_timer(setup, statement, name, storage, fill, flow, base=None, n=10):
base = print_timer(
setup_2d,
"H, *ledges = np.histogram2d(*vals, bins=bins, range=ranges)",
name="Numpy",
name="NumPy",
storage="uint64",
fill="",
flow="no",
Expand Down
2 changes: 1 addition & 1 deletion src/boost_histogram/_internal/hist.py
Expand Up @@ -648,7 +648,7 @@ def to_numpy(
self, flow: bool = False, *, dd: bool = False, view: bool = False
) -> Union[Tuple[np.ndarray, ...], Tuple[np.ndarray, Tuple[np.ndarray, ...]]]:
"""
Convert to a Numpy style tuple of return arrays. Edges are converted to
Convert to a NumPy style tuple of return arrays. Edges are converted to
match NumPy standards, with upper edge inclusive, unlike
boost-histogram, where upper edge is exclusive.

Expand Down
2 changes: 1 addition & 1 deletion src/boost_histogram/_internal/view.py
Expand Up @@ -24,7 +24,7 @@ def __getitem__(self, ind: StrIndex) -> np.ndarray:
return sliced # type: ignore

def __repr__(self) -> str:
# Numpy starts the ndarray class name with "array", so we replace it
# NumPy starts the ndarray class name with "array", so we replace it
# with our class name
return f"{self.__class__.__name__}(\n " + repr(self.view(np.ndarray))[6:]

Expand Down
2 changes: 1 addition & 1 deletion src/boost_histogram/numpy.py
Expand Up @@ -38,7 +38,7 @@ def histogramdd(

if normed is not None:
raise KeyError(
"normed=True is not recommended for use in Numpy, and is not supported in boost-histogram; use density=True instead"
"normed=True is not recommended for use in NumPy, and is not supported in boost-histogram; use density=True instead"
)
if density and histogram is not None:
raise KeyError(
Expand Down
2 changes: 1 addition & 1 deletion src/register_accumulators.cpp
Expand Up @@ -59,7 +59,7 @@ decltype(auto) make_buffer() {

void register_accumulators(py::module& accumulators) {
// Naming convention:
// If a value is publically available in Boost.Histogram accumulators
// If a value is publicly available in Boost.Histogram accumulators
// as a method, it has the same name in the numpy record array.
// If it is not available except through a computation, it has
// the same name as the private property without the trailing _.
Expand Down
2 changes: 1 addition & 1 deletion src/register_axis.cpp
Expand Up @@ -55,7 +55,7 @@ void register_axes(py::module& mod) {
"bins"_a,
"start"_a,
"stop"_a,
"tranform"_a)
"transform"_a)
.def_property_readonly("transform", [](const axis::regular_trans& self) {
return self.transform();
});
Expand Down
2 changes: 1 addition & 1 deletion tests/test_axis.py
Expand Up @@ -88,7 +88,7 @@ def test_metadata(axis, args, opt, kwargs):


# The point of this ABC is to force all the tests listed here to be implemented
# for each axis type. PyTest instantiates these test classes for us, so missing
# for each axis type. Pytest instantiates these test classes for us, so missing
# one really does fail the test.
class Axis(abc.ABC):
@abc.abstractmethod
Expand Down
2 changes: 1 addition & 1 deletion tests/test_histogram.py
Expand Up @@ -733,7 +733,7 @@ def test_pickle_bool():
assert_array_equal(a.view(), b.view())


# Numpy tests
# NumPy tests


def test_numpy_conversion_0():
Expand Down