Skip to content

Commit

Permalink
Removed warnings when setting a style bypass value for exotic properties
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemchak committed Jul 21, 2023
1 parent 2fcf7e5 commit ca3bf69
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/release/release_1.8.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The themes for this release are:

* Bug fixes in tables.py and style_defaults.py
* Update python-igraph name to igraph
* Cleaned up warnings when setting style bypass properties


API Changes
Expand Down
3 changes: 2 additions & 1 deletion doc/release_log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ Release Log

py4cytoscape 1.8.0
-------------------
Release date: dd mmm yyyy
Release date: 21 Jul 2023

* Allowed load_table_data() to handle lists containing float, int and bool instead of just str
* Fixed base_url= not recognized for update_style_defaults() and set_visual_property_default()
* Update python-igraph name to igraph
* Clean up property value warnings for set_node_property_bypass() and set_edge_property_bypass()


Release notes
Expand Down
33 changes: 31 additions & 2 deletions py4cytoscape/style_bypasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,22 @@ def set_node_property_bypass(node_names, new_values, visual_property, bypass=Tru
elif visual_property in NODE_LABEL_PROPERTIES | NODE_TOOLTIP_PROPERTIES | NODE_FONT_FACE_PROPERTIES:
new_values = verify_strs(new_values)
else:
show_error(f'Warning: setting unknown node bypass property "{visual_property}"')
# There are a bunch of properties that we can validate when we're next in a major development.
# It takes a lot to test these validations, so we don't take this lightly. The NODE properties
# we're not validating are: NODE, NODE_BORDER_STROKE, NODE_CUSTOMGRAPHICS_SIZE_1..9, NODE_CUSTOMPAINT_1..9,
# NODE_DEPTH, NODE_LABEL_BACKGROUND_COLOR, NODE_LABEL_BACKGROUND_SHAPE, NODE_LABEL_BACKGROUND_TRANSPARENCY,
# NODE_LABEL_FONT_FACE, NODE_LABEL_POSITION, NODE_LABEL_ROTATION, NODE_LABEL_WIDTH,
# NODE_NESTED_NETWORK_IMAGE_VISIBLE, NODE_PAINT, NODE_SELECTED_PAINT, NODE_X_LOCATION, NODE_Y_LOCATION,
# NODE_Z_LOCATION
# So, the validation we *do* do should be considered an early convenience, as it's incomplete. Of course, if
# a value isn't acceptable to CyREST, an error will be generated by CyREST. So, the above validation is
# somewhat redundant. The major exception is with color properties, which should be passed to CyREST as
# hex values (e.g., 0x123456). Color validation converts color words (e.g., RED) to hex values, so
# the caller must pass unvalidated color properties (e.g., NODE_LABEL_BACKGROUND_COLOR) as only hex values.
# Given this, we're removing the warning we were giving for unvalidated properties, as it's more of a
# worry for users than it's worth:
# show_error(f'Warning: setting unknown node bypass property "{visual_property}"')
pass

# there can be more than one node.SUID per node.name!
# 'node.SUIDs' and 'new.values' must have the same length
Expand Down Expand Up @@ -309,7 +324,21 @@ def set_edge_property_bypass(edge_names, new_values, visual_property, bypass=Tru
elif visual_property in EDGE_LABEL_PROPERTIES | EDGE_TOOLTIP_PROPERTIES | EDGE_FONT_FACE_PROPERTIES:
new_values = verify_strs(new_values)
else:
show_error(f'Warning: setting unknown edge bypass property "{visual_property}"')
# There are a bunch of properties that we can validate when we're next in a major development.
# It takes a lot to test these validations, so we don't take this lightly. The EDGE properties
# we're not validating are: EDGE, EDGE_BEND, EDGE_CURVED, EDGE_LABEL_AUTOROTATE, EDGE_LABEL_BACKGROUND_COLOR,
# EDGE_LABEL_BACKGROUND_SHAPE, EDGE_LABEL_BACKGROUND_TRANSPARENCY, EDGE_LABEL_FONT_SIZE, EDGE_LABEL_POSITION,
# EDGE_LABEL_ROTATION, EDGE_LABEL_WIDTH, EDGE_PAINT, EDGE_SELECTED, EDGE_SOURCE_ARROW_SIZE, EDGE_STACKING,
# EDGE_STACKING_DENSITY, EDGE_TARGET_ARROW_SELECTED_PAINT, EDGE_TARGET_ARROW_SIZE, EDGE_WIDTH, EDGE_Z_ORDER
# So, the validation we *do* do should be considered an early convenience, as it's incomplete. Of course, if
# a value isn't acceptable to CyREST, an error will be generated by CyREST. So, the above validation is
# somewhat redundant. The major exception is with color properties, which should be passed to CyREST as
# hex values (e.g., 0x123456). Color validation converts color words (e.g., RED) to hex values, so
# the caller must pass unvalidated color properties (e.g., EDGE_LABEL_BACKGROUND_COLOR) as only hex values.
# Given this, we're removing the warning we were giving for unvalidated properties, as it's more of a
# worry for users than it's worth:
# show_error(f'Warning: setting unknown edge bypass property "{visual_property}"')
pass

# there can be more than one edge.SUID per edge.name!
# 'edge.SUIDs' and 'new.values' must have the same length
Expand Down

0 comments on commit ca3bf69

Please sign in to comment.