Skip to content

Commit

Permalink
Fixed issue where dir() returned duplicate values when property is a …
Browse files Browse the repository at this point in the history
…child node
  • Loading branch information
markheik committed May 10, 2023
1 parent df51eb5 commit a7d61c4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
13 changes: 7 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Version 0.5.4
* `device.factory_reset` now raises an exception if the factory reset was not successful (`#243`).
* Fixed issue where calling a `Node` with `dir()` returned duplicate values on some nodes.

## Version 0.5.3
* Add internal trigger to SHFQA sweeper class.
Expand Down Expand Up @@ -29,7 +30,7 @@
* Sweeper Module
* DAQ Module
* Renamed `zhinst.toolkit.nodetree.node.WildcardResult` to `zhinst.toolkit.nodetree.helpers.NodeDict`
* Added `active_validation` argument to `CommandTable`. By disabling it, `CommandTable` does not actively
* Added `active_validation` argument to `CommandTable`. By disabling it, `CommandTable` does not actively
validate the inputs and therefore it improves the speed for command table creation.
* Adapt `awg.enable_sequencer` to check the acknowledged value instead of using `wait_for_state_change`. This makes it much more stable when used with short sequences.
* Fix issue with downloading waveforms from the device. This issue prevented reading waveforms from any other than the base channel.
Expand All @@ -45,7 +46,7 @@
* shfqa.qachannels[n].readout.multistate.qudits[m].configure(settings)
* shfqa.qachannels[n].readout.multistate.get_qudits_results()
* Added new example for the multistate discrimination (shfqa_multistate_discrimination) for the SHFQA
* Fixed issue `#181` (Wrong _device_type of awg node of UHFQA/UHFLI) which prevented
* Fixed issue `#181` (Wrong _device_type of awg node of UHFQA/UHFLI) which prevented
the compilation of sequences.
* Waveform validation moved from the `write_to_waveform_memory` into `Waveforms.validate`
* Command Table `$schema` key removed from the output of `CommandTable.as_dict` function
Expand All @@ -59,9 +60,9 @@
* For all LabOne modules forward the `execute` function from the zhinst-core in zhinst-toolkit

## Version 0.4.0
* Add new class `zhinst.toolkit.Sequence` that allows a more flexible use of
* Add new class `zhinst.toolkit.Sequence` that allows a more flexible use of
sequences in toolkit (`#141`).
* Add support for session wide transactions that bundle set command from all
* Add support for session wide transactions that bundle set command from all
devices connected to the data server. (`#134`)
* Add `from_existing_connection()` to `zhinst.toolkit.Session` to help reusing the existing DataServer connection.
* Bugfix: Nodes with nameless options don't raise an exception when their enum attribute is called (`#165`).
Expand All @@ -76,9 +77,9 @@
## Version 0.3.5
* Adapt AWG Waveform upload (`write_to_waveform_memory`) to append to existing transactions.
* Make consistency validate during waveform upload optional (new flag `validate` in `write_to_waveform_memory`).
* Add `get_sequence_snippet` function to `zhinst.toolkit.Waveforms` class.
* Add `get_sequence_snippet` function to `zhinst.toolkit.Waveforms` class.
The function is able to generated a sequence code snippet that defines and assigns
the waveforms for this object. Additional meta information like an optional name
the waveforms for this object. Additional meta information like an optional name
or the output configuration can be specified through a newly added `Wave` class from `zhinst.toolkit.Waveforms`.
* Getting a value by calling a wildcard node now returns `zhinst.toolkit.nodetree.node.WildcardResult`

Expand Down
6 changes: 5 additions & 1 deletion src/zhinst/toolkit/nodetree/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,11 @@ def __repr__(self):
def __dir__(self):
dir_info = list(self._next_layer)
for var, value in vars(self.__class__).items():
if isinstance(value, property) and not var.startswith("_"):
if (
isinstance(value, property)
and not var.startswith("_")
and var not in dir_info
):
dir_info.append(var)
return dir_info

Expand Down
16 changes: 16 additions & 0 deletions tests/test_nodetree.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,22 @@ def sub_one(value):
tree.demods.waves[0].node_info.unit


def test_node_dir_property_not_duplicated(connection):
class MockNode(Node):
def __init__(self, root: "NodeTree", tree: tuple):
self._root = root
self._tree = tree

@property
def features(self):
pass

tree = NodeTree(connection, "DEV1234")
assert "features" in dir(tree)
node = MockNode(tree, ())
assert len(dir(node)) == len(set(dir(node)))


def test_wildcard_node(connection):
tree = NodeTree(connection, "DEV1234")
wildcard_node = tree.demods["*"].rate
Expand Down

0 comments on commit a7d61c4

Please sign in to comment.