Skip to content

Choropleth language independent settings#194

Merged
VesnaT merged 2 commits intobiolab:masterfrom
janezd:choroplet-language-independent-settings
Feb 23, 2026
Merged

Choropleth language independent settings#194
VesnaT merged 2 commits intobiolab:masterfrom
janezd:choroplet-language-independent-settings

Conversation

@janezd
Copy link
Collaborator

@janezd janezd commented Sep 24, 2025

Issue

Fixes #192. Also fixes #195.

Based on #193.

Description of changes
  • Use aggregation name as a setting.
  • FIxes for tests that fail after "tests on nasty data" were added to the widget test base.
Includes
  • Code changes
  • Tests

@janezd janezd changed the title Choroplet language independent settings Choropleth language independent settings Sep 24, 2025
@janezd janezd force-pushed the choroplet-language-independent-settings branch from 8c65369 to 98fbfc5 Compare September 24, 2025 19:21
Copy link
Collaborator

@VesnaT VesnaT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I open a saved workflow, the Show setting does not reflect the correct state.

@janezd janezd force-pushed the choroplet-language-independent-settings branch from 98fbfc5 to 47efa39 Compare February 21, 2026 10:37
@janezd
Copy link
Collaborator Author

janezd commented Feb 21, 2026

@VesnaT, you probably mean the aggregation type, which was reset to "Count"? (It didn't work before -- see #195 --, either, but failed in a different way).

I fixed this and merged it into the previous commit. In case you already looked into the code (likely not), this is what I changed now.

--- a/orangecontrib/geo/widgets/owchoropleth.py
+++ b/orangecontrib/geo/widgets/owchoropleth.py
@@ -787,7 +787,7 @@ class OWChoropleth(OWWidget):
             self.clear(cache=True)
             self.input_changed.emit(data)
             self.setup_plot()
-        self.update_agg()
+        self.update_agg(from_context=True)
         self.apply_selection()
         self.unconditional_commit()

@@ -816,15 +816,22 @@ class OWChoropleth(OWWidget):
         else:
             self.agg_attr = None
         self.attr_lat, self.attr_lon = lat, lon
+        self.agg_func = DEFAULT_AGG_FUNCS.get(type(self.agg_attr),
+                                              DEFAULT_AGG_FUNC)

     def on_agg_func_changed(self, value):
         if value:
             self.agg_func = AGG_FUNCS[value].name
         self.graph.update_colors()

-    def update_agg(self):
-        # Store previous aggregation to keep it, unless it was the only choice
-        current_agg = self.agg_func_combo.count() > 1 and self.agg_func
+    def update_agg(self, *, from_context=False):
+        # This function updates the list of aggregations when the aggregation
+        # attribute is set on open context or on user interaction.
+        # If the currently selected aggregation was the only available option
+        # (thus: enforced) and we haven't just gotten this option from the context,
+        # we reset the option to the default for this attribute type.
+        current_agg = (from_context or self.agg_func_combo.count() > 1) \
+                      and self.agg_func

@janezd janezd force-pushed the choroplet-language-independent-settings branch 3 times, most recently from 20c6a85 to 3d94571 Compare February 21, 2026 19:19
@janezd janezd requested a review from Copilot February 21, 2026 19:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses cross-language workflow compatibility for the Choropleth widget by making the stored aggregation setting language-independent (using a stable aggregation identifier instead of the displayed/translatable label), and updates migrations/tests accordingly.

Changes:

  • Store agg_func as a stable internal name (e.g., "mean", "mode", "min") and map it to a display label for the UI/tooltip.
  • Add settings/context migration to convert older saved contexts to the new agg_func representation (settings version bump to 3).
  • Update widget tests and adjust some related widget logic and dependency pins.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tox.ini Updates “oldest” dependency constraints for numpy/pandas.
orangecontrib/geo/widgets/tests/test_owchoropleth.py Updates expectations for internal agg_func values and adds migration/settings retrieval tests.
orangecontrib/geo/widgets/owgeotransform.py Tightens None checks and prevents running when lat/lon attrs are missing.
orangecontrib/geo/widgets/owgeocoding.py Refactors commit path to handle encode/decode returning None more safely.
orangecontrib/geo/widgets/owchoropleth.py Implements language-independent aggregation setting, adds mapping to display labels, and migrates contexts to v3.
i18n/si/msgs.jaml Updates extracted strings to match the new tooltip/display mapping and removed symbols.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@janezd janezd force-pushed the choroplet-language-independent-settings branch from 3d94571 to c24458f Compare February 21, 2026 20:18
@janezd janezd force-pushed the choroplet-language-independent-settings branch from c24458f to f5f8230 Compare February 21, 2026 20:22
@VesnaT VesnaT merged commit 56c3c45 into biolab:master Feb 23, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Choropleth doesn't restore aggregation function setting Choropleth can't load workflows stored in another language

3 participants