Skip to content

Commit ef3c9f1

Browse files
committed
change to status message and more tidy up of weave patterns
1 parent bbfe236 commit ef3c9f1

File tree

2 files changed

+32
-34
lines changed

2 files changed

+32
-34
lines changed

tiling-explorer-2.py

+27-29
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import marimo
22

3-
__generated_with = "0.11.9"
3+
__generated_with = "0.11.13"
44
app = marimo.App(
55
width="medium",
66
app_title="MapWeaver",
@@ -13,7 +13,7 @@
1313
def _(mo):
1414
mo.hstack([
1515
mo.md(f"# MapWeaver ~ tiled maps of complex data"),
16-
mo.md("v2025.03.06-17:16")
16+
mo.md("v2025.03.06-21:45")
1717
]).center()
1818
return
1919

@@ -45,13 +45,16 @@ def marimo_states(available_palettes, dummy_data_file, mo):
4545
get_input_data, set_input_data = mo.state(dummy_data_file)
4646
get_palettes, set_palettes = mo.state(available_palettes)
4747
get_reversed, set_reversed = mo.state([False] * 12)
48+
get_status_message, set_status_message = mo.state("STATUS All good!")
4849
return (
4950
get_input_data,
5051
get_palettes,
5152
get_reversed,
53+
get_status_message,
5254
set_input_data,
5355
set_palettes,
5456
set_reversed,
57+
set_status_message,
5558
)
5659

5760

@@ -162,10 +165,13 @@ def build_variable_and_palette_dropdowns(
162165
pd,
163166
set_palettes,
164167
set_reversed,
168+
set_status_message,
165169
):
166170
available_vars = [col for col in gdf.columns if not "geom" in col
167171
and pd.api.types.is_numeric_dtype(gdf[col].dtype)]
168-
repeated_variables = len(available_vars) < num_tiles.value
172+
173+
if len(available_vars) < num_tiles.value:
174+
set_status_message(f"WARNING! More tile elements ({num_tiles.value}) than variables ({len(available_vars)})")
169175

170176
_chosen_vars = available_vars
171177
_chosen_palettes = get_palettes()[:len(available_vars)]
@@ -179,7 +185,7 @@ def build_variable_and_palette_dropdowns(
179185
rev_pals = mo.ui.array(
180186
[mo.ui.switch(_chosen_reversed[i])
181187
for i, id in enumerate(_chosen_reversed)], on_change=set_reversed)
182-
return available_vars, pals, repeated_variables, rev_pals, vars
188+
return available_vars, pals, rev_pals, vars
183189

184190

185191
@app.cell
@@ -189,18 +195,9 @@ def variable_palette_map_header(mo):
189195

190196

191197
@app.cell
192-
def status_panel(
193-
gdf,
194-
get_numeric_variables,
195-
mo,
196-
num_tiles,
197-
repeated_variables,
198-
):
199-
if repeated_variables:
200-
_warning_text = f"WARNING! {len(get_numeric_variables(gdf))} variables but {num_tiles.value} elements in tiling"
201-
_warning = mo.md(f"<span style='background-color:pink;font-face:sans-serif;padding:2px;'>{_warning_text}</span>")
202-
else:
203-
_warning = mo.md(f"<span style='background-color:lightgreen;font-face:sans-serif;padding:2px;'>STATUS All good!</span>")
198+
def status_panel(get_status_message, mo):
199+
_bkgd = "lightgreen" if get_status_message() == "STATUS All good!" else "pink"
200+
_warning = mo.md(f"<span style='background-color:{_bkgd};font-face:sans-serif;padding:2px;'>{get_status_message()}</span>")
204201

205202
_warning.center()
206203
return
@@ -470,7 +467,8 @@ def get_base_tile_unit():
470467
weave_type=spec["weave_type"],
471468
spacing=spacing.value,
472469
strands=spec["strands"],
473-
n=1 if "plain" in family.value else get_over_under(tile_spec["over_under"].value),
470+
n=get_over_under(tile_spec["over_under"].value) \
471+
if spec["weave_type"] in ["twill", "basket"] else 1,
474472
aspect=tile_spec["aspect"].value,
475473
crs=3857 if gdf is None else gdf.crs)
476474
return (get_base_tile_unit,)
@@ -624,15 +622,15 @@ def setup_tilings_dictionary():
624622
"archimedean 3.6.3.6": {"type":"tiling", "tiling_type": "archimedean", "code": "3.6.3.6"},
625623
"archimedean 3.12.12": {"type":"tiling", "tiling_type": "archimedean", "code": "3.12.12"},
626624
"square-slice 3": {"type":"tiling", "tiling_type": "square-slice", "n": 3},
627-
"twill weave ab|c-": {"type":"weave", "weave_type": "twill", "strands": "ab|c-", "n": "2"},
628-
"basket weave ab|c-": {"type":"weave", "weave_type": "basket", "strands": "ab|c-", "n": "2"},
625+
# "twill weave ab|c-": {"type":"weave", "weave_type": "twill", "strands": "ab|c-", "n": "2"},
626+
# "basket weave ab|c-": {"type":"weave", "weave_type": "basket", "strands": "ab|c-", "n": "2"},
629627
},
630628
4: {
631629
"laves 3.3.4.3.4": {"type":"tiling", "tiling_type": "laves", "code": "3.3.4.3.4"},
632630
"basket weave ab|cd": {"type":"weave", "weave_type": "basket", "strands": "ab|cd", "n": "2"},
633631
"twill weave ab|cd": {"type":"weave", "weave_type": "twill", "strands": "ab|cd", "n": "2"},
634-
"basket weave ab|cd-": {"type":"weave", "weave_type": "basket", "strands": "ab|cd", "n": "2,3"},
635-
"twill weave ab|cd-": {"type":"weave", "weave_type": "twill", "strands": "ab|cd", "n": "2,3"},
632+
"basket weave ab|cd-": {"type":"weave", "weave_type": "basket", "strands": "ab|cd-", "n": "3"},
633+
"twill weave ab|cd-": {"type":"weave", "weave_type": "twill", "strands": "ab|cd-", "n": "3"},
636634
# "laves 4.8.8": {"type":"tiling", "tiling_type": "laves", "code": "4.8.8"},
637635
"crosses 4": {"type":"tiling", "tiling_type": "crosses", "n": 4},
638636
"square-slice 4": {"type":"tiling", "tiling_type": "square-slice", "n": 4},
@@ -644,8 +642,8 @@ def setup_tilings_dictionary():
644642
5: {
645643
"square-colouring 5": {"type":"tiling", "tiling_type": "square-colouring", "n": 5},
646644
"crosses 5": {"type":"tiling", "tiling_type": "crosses", "n": 5},
647-
"twill weave abc|de": {"type":"weave", "weave_type": "twill", "strands": "abc|de-", "n": "3,3"},
648-
"basket weave abc|de": {"type":"weave", "weave_type": "basket", "strands": "abc|de-", "n": "3,3"},
645+
"twill weave abc|de": {"type":"weave", "weave_type": "twill", "strands": "abc|de", "n": "3"},
646+
"twill weave abc|de-": {"type":"weave", "weave_type": "twill", "strands": "abc|de-", "n": "3"},
649647
"hex-colouring 5": {"type":"tiling", "tiling_type": "hex-colouring", "n": 5},
650648
"hex-slice 5": {"type":"tiling", "tiling_type": "hex-slice", "n": 5},
651649
"square-slice 5": {"type":"tiling", "tiling_type": "square-slice", "n": 5},
@@ -659,8 +657,8 @@ def setup_tilings_dictionary():
659657
"laves 3.12.12": {"type":"tiling", "tiling_type": "laves", "code": "3.12.12"},
660658
"basket weave abc|def": {"type":"weave", "weave_type": "basket", "strands": "abc|def", "n": "3"},
661659
"twill weave abc|def": {"type":"weave", "weave_type": "twill", "strands": "abc|def", "n": "3"},
662-
"basket weave abc|def-": {"type":"weave", "weave_type": "basket", "strands": "abc|def-", "n": "3"},
663-
"twill weave abc|def-": {"type":"weave", "weave_type": "twill", "strands": "abc|def-", "n": "3"},
660+
"basket weave abc|def-": {"type":"weave", "weave_type": "basket", "strands": "abc|def-", "n": "4"},
661+
"twill weave abc|def-": {"type":"weave", "weave_type": "twill", "strands": "abc|def-", "n": "4"},
664662
"archimedean 3.3.4.3.4": {"type":"tiling", "tiling_type": "archimedean", "code": "3.3.4.3.4"},
665663
"archimedean 3.4.6.4": {"type":"tiling", "tiling_type": "archimedean", "code": "3.4.6.4"},
666664
"archimedean 4.6.12": {"type":"tiling", "tiling_type": "archimedean", "code": "4.6.12"},
@@ -671,21 +669,21 @@ def setup_tilings_dictionary():
671669
"hex-colouring 7": {"type":"tiling", "tiling_type": "hex-colouring", "n": 7},
672670
"crosses 7": {"type":"tiling", "tiling_type": "crosses", "n": 7},
673671
"hex-dissection 7": {"type":"tiling", "tiling_type": "hex-dissection", "n": 7},
674-
"basket weave abcd|efg-": {"type":"weave", "weave_type": "basket", "strands": "abcd|defg-", "n": "2"},
675-
"twill weave abcd|efg-": {"type":"weave", "weave_type": "twill", "strands": "abcd|defg-", "n": "2"},
672+
"twill weave abcd|efg": {"type":"weave", "weave_type": "twill", "strands": "abcd|defg", "n": "4"},
673+
"twill weave abcd|efg-": {"type":"weave", "weave_type": "twill", "strands": "abcd|defg-", "n": "4"},
676674
"square-colouring 7": {"type":"tiling", "tiling_type": "square-colouring", "n": 7},
677675
"hex-slice 7": {"type":"tiling", "tiling_type": "hex-slice", "n": 7},
678676
"square-slice 7": {"type":"tiling", "tiling_type": "square-slice", "n": 7},
679677
},
680678
8: {
681679
"square-slice 8": {"type":"tiling", "tiling_type": "square-slice", "n": 8},
682-
"basket weave abcd|efgh": {"type":"weave", "weave_type": "basket", "strands": "abcd|efgh", "n": "2"},
683-
"twill weave abcd|efgh": {"type":"weave", "weave_type": "twill", "strands": "abcd|efgh", "n": "2"},
680+
"basket weave abcd|efgh": {"type":"weave", "weave_type": "basket", "strands": "abcd|efgh", "n": "4"},
684681
"square-colouring 8": {"type":"tiling", "tiling_type": "square-colouring", "n": 8},
685682
"hex-slice 8": {"type":"tiling", "tiling_type": "hex-slice", "n": 8},
686683
"hex-colouring 8": {"type":"tiling", "tiling_type": "hex-colouring", "n": 8},
687684
},
688685
9: {
686+
# "cube weave abc|def|ghi": {"type":"weave", "weave_type": "cube", "strands": "abc|def|ghi"},
689687
"hex-slice 9": {"type":"tiling", "tiling_type": "hex-slice", "n": 9},
690688
"square-colouring 9": {"type":"tiling", "tiling_type": "square-colouring", "n": 9},
691689
"hex-colouring 9": {"type":"tiling", "tiling_type": "hex-colouring", "n": 9},

tiling-explorer-2/index.html

+5-5
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)