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

Document redundancy deletion #306

Open
LovelyBuggies opened this issue Feb 24, 2020 · 1 comment
Open

Document redundancy deletion #306

LovelyBuggies opened this issue Feb 24, 2020 · 1 comment
Labels
docs Documentation good first issue Good for newcomers

Comments

@LovelyBuggies
Copy link
Collaborator

The example code provided in simple_numpy.py might not meet the criteria for high coupling, as it is very similar to the code in simple_2d.py. I recommend you to delete this redundancy example OR possibly add more comments to the simple_2d.py like this:

import boost_histogram as bh
import matplotlib.pyplot as plt
import numpy as np

# Create 2d-histogram with two axes with 20 equidistant bins from -3 to 3
h = bh.Histogram(
    bh.axis.Regular(50, -3, 3, metadata="x"), bh.axis.Regular(50, -3, 3, metadata="y")
)

# 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_000)
y = np.random.randn(1_000_000)

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

# Get numpy.histogram compatible representation of the histogram
# or create a view of the counts (no copy involved)
w, x, y = h.to_numpy()
# x = h.axes[0].edges
# y = h.axes[1].edges
# w = h.view()

# Draw the count matrix
fig, ax = plt.subplots()
mesh = ax.pcolormesh(x, y, w.T)
ax.set_xlabel(h.axes[0].metadata)
ax.set_ylabel(h.axes[1].metadata)
fig.colorbar(mesh)
plt.savefig("simple_2d.png")
@LovelyBuggies
Copy link
Collaborator Author

Same applies to simple_weight.py and simple_log_weight.py. I recommend to remove simple_weight.py example.

@henryiii henryiii added the docs Documentation label Apr 15, 2022
@gohil-jay gohil-jay added the good first issue Good for newcomers label Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation good first issue Good for newcomers
Projects
Status: No status
Development

No branches or pull requests

3 participants