Skip to content

ndarray.ptp -> np.ptp for numpy v2 #524

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 4 commits into from
Jun 18, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/source/user_guide/gpu.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ You can get more detailed info on each adapter like this::

import pprint
for a in fpl.enumerate_adapters():
pprint.pprint(a.request_adapter_info())
pprint.pprint(a.info)

General description of the fields:
* vendor: GPU manufacturer
Expand Down Expand Up @@ -265,7 +265,9 @@ You can select an adapter by passing one of the ``wgpu.GPUAdapter`` instances re
to ``fpl.select_adapter()``::

# get info or summary of all adapters to pick an adapter
print([a.request_adapter_info() for a in fpl.enumerate_adapters()])
import pprint
for a in fpl.enumerate_adapters():
pprint.pprint(a.info)

# example, pick adapter at index 2
chosen_gpu = fpl.enumerate_adapters()[2]
Expand Down
40 changes: 0 additions & 40 deletions examples/notebooks/linear_region_selector.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -93,46 +93,6 @@
"fig.show(maintain_aspect=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2f29e913-c4f8-44a6-8692-eb14436849a5",
"metadata": {},
"outputs": [],
"source": [
"sine_graphic_x.data[:, 1].ptp()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1947a477-5dd2-4df9-aecd-6967c6ab45fe",
"metadata": {},
"outputs": [],
"source": [
"np.clip(-0.1, 0, 10)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "18e10277-6d5d-42fe-8715-1733efabefa0",
"metadata": {},
"outputs": [],
"source": [
"ls_y.selection"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8e9c42b9-60d2-4544-96c5-c8c6832b79e3",
"metadata": {},
"outputs": [],
"source": [
"ls_y.get_selected_indices()"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
2 changes: 1 addition & 1 deletion examples/tests/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_wgpu_backend():
"""
Query the configured wgpu backend driver.
"""
code = "import wgpu.utils; info = wgpu.utils.get_default_device().adapter.request_adapter_info(); print(info['adapter_type'], info['backend_type'])"
code = "import wgpu.utils; info = wgpu.utils.get_default_device().adapter.info; print(info['adapter_type'], info['backend_type'])"
result = subprocess.run(
[
sys.executable,
Expand Down
4 changes: 2 additions & 2 deletions fastplotlib/graphics/line_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def _get_linear_selector_init_args(self, axis, padding):
bounds = (xmin, value_25p)
limits = (xmin, xmax)
# size from orthogonal axis
size = bbox[:, 1].ptp() * 1.5
size = np.ptp(bbox[:, 1]) * 1.5
# center on orthogonal axis
center = bbox[:, 1].mean()

Expand All @@ -472,7 +472,7 @@ def _get_linear_selector_init_args(self, axis, padding):
bounds = (xmin, value_25p)
limits = (xmin, xmax)

size = bbox[:, 0].ptp() * 1.5
size = np.ptp(bbox[:, 0]) * 1.5
# center on orthogonal axis
center = bbox[:, 0].mean()

Expand Down
4 changes: 2 additions & 2 deletions fastplotlib/legends/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def add_graphic(self, graphic: Graphic, label: str = None):
# get width of widest LegendItem in previous column to add to x_pos offset for this column
for item in prev_column_items:
bbox = item.world_object.get_world_bounding_box()
width, height, depth = bbox.ptp(axis=0)
width, height, depth = np.ptp(bbox, axis=0)
max_width = max(max_width, width)

# x position offset for this new column
Expand Down Expand Up @@ -278,7 +278,7 @@ def add_graphic(self, graphic: Graphic, label: str = None):
def _reset_mesh_dims(self):
bbox = self._legend_items_group.get_world_bounding_box()

width, height, _ = bbox.ptp(axis=0)
width, height, _ = np.ptp(bbox, axis=0)

self._mesh.geometry.positions.data[mesh_masks.x_right] = width + 7
self._mesh.geometry.positions.data[mesh_masks.x_left] = -5
Expand Down
4 changes: 2 additions & 2 deletions fastplotlib/utils/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def _notebook_print_banner():

# print logo and adapter info
adapters = [a for a in wgpu.gpu.enumerate_adapters()]
adapters_info = [a.request_adapter_info() for a in adapters]
adapters_info = [a.info for a in adapters]

default_adapter_info = wgpu.gpu.request_adapter().request_adapter_info()
default_adapter_info = wgpu.gpu.request_adapter().info
default_ix = adapters_info.index(default_adapter_info)

if len(adapters) > 0:
Expand Down
2 changes: 1 addition & 1 deletion fastplotlib/widgets/histogram_lut.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def _calculate_histogram(self, data):
# used if data ptp <= 10 because event things get weird
# with tiny world objects due to floating point error
# so if ptp <= 10, scale up by a factor
self._scale_factor: int = max(1, 100 * int(10 / data_ss.ptp()))
self._scale_factor: int = max(1, 100 * int(10 / np.ptp(data_ss)))

edges = edges * self._scale_factor

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

install_requires = [
"numpy>=1.23.0",
"wgpu>=0.15.1",
"wgpu>=0.16.0",
"pygfx>=0.1.14",
]

Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy