Skip to content

Commit

Permalink
feat: fix time axis selection and fix label for node tests
Browse files Browse the repository at this point in the history
  • Loading branch information
josuemtzmo committed Jul 12, 2022
1 parent dc0f8fc commit 4c909c5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
hooks:
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.1.0
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
Expand Down
12 changes: 8 additions & 4 deletions blendernc/nodes/selecting/BlenderNC_NT_select_axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from collections import defaultdict

import bpy
import numpy as np

from blendernc.core.update_ui import update_node_tree, update_value_and_node_tree
from blendernc.decorators import DrawDecorators, NodesDecorators
Expand Down Expand Up @@ -73,10 +74,10 @@ def draw_buttons(self, context, layout):
layout.prop(self, "axes", text="")
if self.axes:
layout.label(text="Select within range:")
min_val_axes = dataset[self.axes][0].values
max_val_axes = dataset[self.axes][-1].values
min_val_axes = np.array(dataset[self.axes][0].values, dtype=float)
max_val_axes = np.array(dataset[self.axes][-1].values, dtype=float)

layout.label(text="[{0:.2f} - {1:.2f}]".format(min_val_axes, max_val_axes))
layout.label(text="[{0} - {1}]".format(min_val_axes, max_val_axes))
layout.prop(self, "axis_selection", text="")
layout.label(text="INFO: nearest value", icon="INFO")
layout.label(text="will be selected")
Expand All @@ -99,7 +100,10 @@ def update(self):
node_tree = self.rna_type.id_data.name
if self.axes:
dtype = dataset[self.axes].dtype
if dtype != int:
if dtype == "<M8[ns]":
method = "nearest"
val_select = np.array(int(self.axis_selection), dtype="M8[ns]")
elif dtype != int:
method = "nearest"
val_select = self.axis_selection
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/blendernc_nodes.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def test_axis(self):
var = "adt"
format = os.path.basename(file).split(".")
nodes = ["datacubeAxis"]
dims_args = {"Select Axis": {"axis_selection": "time"}}
dims_args = {"Select Axis": {"axes": "time"}}
render_image(file, var, nodes, node_args=dims_args)
file_exist = os.path.isfile(
"./{0}_{1}_image_{2}_{3}.png".format(
Expand Down

0 comments on commit 4c909c5

Please sign in to comment.