-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathelectional_cookbook.py
More file actions
1778 lines (1447 loc) · 55.8 KB
/
Copy pathelectional_cookbook.py
File metadata and controls
1778 lines (1447 loc) · 55.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
"""
Electional Astrology Cookbook
=============================
This cookbook demonstrates Stellium's electional search engine for finding
auspicious times that match specific astrological criteria.
Electional astrology is the art of choosing optimal times for important
undertakings - starting a business, getting married, launching a project,
or creating talismans. The goal is to find moments when planetary positions
support the intended activity.
**Output directory:** `examples/elections/`
Run this cookbook:
source ~/.zshrc && pyenv activate starlight
python examples/electional_cookbook.py
Contents:
---------
Part 1: Basic Searches
1. Simplest search (lambda conditions)
2. Using helper predicates
3. Finding time windows vs moments
4. Search with progress callback
Part 2: Moon Conditions
5. Moon phase requirements
6. Void of course Moon
7. Moon sign restrictions
8. Moon aspects (applying/separating)
Part 3: Planetary Conditions
9. Retrograde avoidance
10. Dignity requirements
11. Combust planets
12. Out of bounds planets
Part 4: Aspect Conditions
13. Requiring specific aspects
14. Avoiding hard aspects
15. Malefic avoidance (Mars/Saturn)
16. Complex aspect combinations
Part 5: House & Angle Conditions
17. Angular planets
18. Avoiding difficult houses
19. Benefics in good houses
Part 6: Composition & Complex Queries
20. AND logic (all_of)
21. OR logic (any_of)
22. NOT logic (not_)
23. Nested boolean expressions
24. The Reddit "Regulus Talisman" query
Part 7: Practical Elections
25. General good times
26. Business launch election
27. Relationship/marriage election
28. Mercury matters (contracts, communication)
29. Mars matters (competition, surgery)
30. Jupiter matters (expansion, luck)
Part 8: Aspect Exactitude
31. Finding moments near exact aspects
32. Tight orb elections
Part 9: Fixed Stars & Angles
33. Fixed star on angle (Regulus rising)
34. Specific degrees on angles
35. The complete Regulus talisman query
Part 10: Planetary Hours
36. Finding planetary hours
37. Jupiter hour elections
38. Combining planetary hours with other conditions
Part 11: Advanced Usage
39. Generator-based iteration (memory efficient)
40. Counting matches without storing
41. Custom lambda conditions
42. Integration with ChartQuery
43. Exporting results
"""
from pathlib import Path
# Stellium imports
from stellium.core.models import ChartLocation
from stellium.electional import (
CHALDEAN_ORDER,
DAY_RULERS,
# Main search class
ElectionalSearch,
all_of,
# Angles and fixed stars
angle_at_degree,
any_of,
# Aspect predicates
aspect_applying,
# Aspect exactitude
aspect_exact_within,
get_planetary_hour,
get_planetary_hours_for_day,
has_aspect,
# House predicates
in_house,
# Planetary hours
in_planetary_hour,
# Dignity predicates
is_dignified,
# Out of bounds predicates
is_out_of_bounds,
is_waning,
# Moon phase predicates
is_waxing,
moon_phase,
no_aspect,
no_hard_aspect,
no_malefic_aspect,
not_,
# Combust predicates
not_combust,
not_debilitated,
not_in_house,
not_out_of_bounds,
# Retrograde predicates
not_retrograde,
# VOC predicates
not_voc,
on_angle,
# Sign predicates
sign_in,
sign_not_in,
star_on_angle,
)
# Create output directory
OUTPUT_DIR = Path(__file__).parent / "elections"
OUTPUT_DIR.mkdir(exist_ok=True)
# Default location for examples (San Francisco)
DEFAULT_LOCATION = ChartLocation(
latitude=37.7749,
longitude=-122.4194,
timezone="America/Los_Angeles",
)
# Shorter date range for faster examples
SHORT_RANGE = ("2025-01-01", "2025-01-15")
MONTH_RANGE = ("2025-01-01", "2025-01-31")
QUARTER_RANGE = ("2025-01-01", "2025-03-31")
def print_header(title: str) -> None:
"""Print a section header."""
print()
print("=" * 70)
print(title)
print("=" * 70)
print()
def print_results(results, max_show: int = 5, detailed: bool = True) -> None:
"""Print search results nicely."""
print(f"Found {len(results)} results")
if not results:
print(" (No matches found)")
return
for i, moment in enumerate(results[:max_show], 1):
chart = moment.chart
moon = chart.get_object("Moon")
print(f"\n{i}. {moment.datetime.strftime('%a %b %d, %Y at %I:%M %p')}")
if detailed and moon:
phase_info = f"{moon.phase.phase_name}" if moon.phase else "unknown"
print(f" Moon: {moon.sign} ({phase_info})")
# Show Moon's applying aspects
applying = []
for asp in chart.aspects:
if asp.object1.name == "Moon" or asp.object2.name == "Moon":
other = (
asp.object2.name
if asp.object1.name == "Moon"
else asp.object1.name
)
if asp.is_applying:
applying.append(f"{asp.aspect_name} {other}")
if applying:
print(f" Applying: {', '.join(applying[:3])}")
if len(results) > max_show:
print(f"\n ... and {len(results) - max_show} more")
def print_windows(windows, max_show: int = 5) -> None:
"""Print window results nicely."""
print(f"Found {len(windows)} windows")
if not windows:
print(" (No windows found)")
return
for i, window in enumerate(windows[:max_show], 1):
print(f"\n{i}. {window}")
moon = window.chart.get_object("Moon")
if moon:
print(f" Moon at start: {moon.sign}")
if len(windows) > max_show:
print(f"\n ... and {len(windows) - max_show} more")
# =============================================================================
# PART 1: BASIC SEARCHES
# =============================================================================
def example_1_simplest_search():
"""
Example 1: Simplest Search with Lambda Conditions
-------------------------------------------------
The most basic way to use ElectionalSearch is with lambda functions.
Each lambda takes a CalculatedChart and returns True/False.
This approach requires no additional imports beyond ElectionalSearch
and gives you full access to the chart object.
"""
print_header("Example 1: Simplest Search (Lambda Conditions)")
print("Query: Find times when Moon is waxing")
print("Method: Using a lambda function")
print()
search = ElectionalSearch(*SHORT_RANGE, DEFAULT_LOCATION)
# Lambda directly accesses chart attributes
results = search.where(lambda c: c.get_object("Moon").phase.is_waxing).find_moments(
max_results=5, step="day"
)
print_results(results)
def example_2_helper_predicates():
"""
Example 2: Using Helper Predicates
----------------------------------
Helper predicates are factory functions that return conditions.
They're more readable than lambdas and handle edge cases properly.
Compare:
lambda c: c.get_object("Moon").phase.is_waxing
vs:
is_waxing()
Both do the same thing, but the predicate is cleaner.
"""
print_header("Example 2: Using Helper Predicates")
print("Query: Moon waxing AND not void of course")
print("Method: Using is_waxing() and not_voc() predicates")
print()
results = (
ElectionalSearch(*SHORT_RANGE, DEFAULT_LOCATION)
.where(is_waxing())
.where(not_voc())
.find_moments(max_results=5, step="day")
)
print_results(results)
def example_3_time_windows():
"""
Example 3: Finding Time Windows vs Moments
------------------------------------------
find_moments() returns individual time points.
find_windows() coalesces adjacent passing moments into windows.
Windows are useful for seeing "good periods" - e.g., "Tuesday 2pm-6pm"
rather than "Tuesday 2pm, 3pm, 4pm, 5pm, 6pm".
"""
print_header("Example 3: Time Windows vs Moments")
search = ElectionalSearch(*SHORT_RANGE, DEFAULT_LOCATION).where(is_waxing())
print("MOMENTS (individual time points):")
moments = search.find_moments(max_results=3, step="4hour")
for m in moments:
print(f" {m.datetime.strftime('%a %b %d at %I:%M %p')}")
print("\nWINDOWS (coalesced periods):")
windows = search.find_windows(step="4hour")
print_windows(windows, max_show=3)
def example_4_progress_callback():
"""
Example 4: Search with Progress Callback
----------------------------------------
Long searches can take a while. Use with_progress() to track progress.
The callback receives (current_step, total_steps).
"""
print_header("Example 4: Progress Callback")
print("Searching with progress reporting...")
print()
steps_shown = [0]
def show_progress(current: int, total: int) -> None:
pct = (current / total) * 100 if total > 0 else 0
if pct >= steps_shown[0] + 25: # Show every 25%
print(f" Progress: {pct:.0f}%")
steps_shown[0] = pct
results = (
ElectionalSearch(*SHORT_RANGE, DEFAULT_LOCATION)
.where(is_waxing())
.where(not_voc())
.with_progress(show_progress)
.find_moments(max_results=3, step="hour")
)
print()
print_results(results, detailed=False)
# =============================================================================
# PART 2: MOON CONDITIONS
# =============================================================================
def example_5_moon_phase():
"""
Example 5: Moon Phase Requirements
----------------------------------
The Moon's phase is crucial in electional astrology:
- Waxing (New to Full): Good for beginnings, growth, increase
- Waning (Full to New): Good for endings, decrease, banishing
- Specific phases: New Moon, Full Moon, quarters, etc.
"""
print_header("Example 5: Moon Phase Requirements")
print("A) Finding waxing Moon times:")
results = (
ElectionalSearch(*SHORT_RANGE, DEFAULT_LOCATION)
.where(is_waxing())
.find_moments(max_results=3, step="day")
)
print_results(results, max_show=3)
print("\n" + "-" * 50)
print("\nB) Finding waning Moon times:")
results = (
ElectionalSearch(*SHORT_RANGE, DEFAULT_LOCATION)
.where(is_waning())
.find_moments(max_results=3, step="day")
)
print_results(results, max_show=3)
print("\n" + "-" * 50)
print("\nC) Finding specific phases (First Quarter or Full):")
results = (
ElectionalSearch(*MONTH_RANGE, DEFAULT_LOCATION)
.where(moon_phase(["First Quarter", "Full"]))
.find_moments(max_results=3, step="4hour")
)
print_results(results, max_show=3)
def example_6_void_of_course():
"""
Example 6: Void of Course Moon
------------------------------
A void-of-course Moon has made its last major aspect before
changing signs. Traditional electional astrology avoids VOC periods
for important undertakings - things "come to nothing."
not_voc() is one of the most important electional filters.
"""
print_header("Example 6: Void of Course Moon")
print("Query: Find times when Moon is NOT void of course")
print()
# Not VOC with traditional aspects (Sun through Saturn)
print("A) Using traditional aspects (Sun-Saturn):")
results = (
ElectionalSearch(*SHORT_RANGE, DEFAULT_LOCATION)
.where(not_voc(mode="traditional"))
.find_moments(max_results=3, step="4hour")
)
print_results(results, max_show=3)
print("\n" + "-" * 50)
# Not VOC with modern aspects (includes Uranus, Neptune, Pluto)
print("\nB) Using modern aspects (includes outers):")
results = (
ElectionalSearch(*SHORT_RANGE, DEFAULT_LOCATION)
.where(not_voc(mode="modern"))
.find_moments(max_results=3, step="4hour")
)
print_results(results, max_show=3)
def example_7_moon_sign():
"""
Example 7: Moon Sign Restrictions
---------------------------------
Some Moon signs are better for certain activities:
- Moon in Scorpio: "Fall" - Moon is weakened
- Moon in Capricorn: "Detriment" - Moon is uncomfortable
- Moon in Taurus: "Exaltation" - Moon is strengthened
- Moon in Cancer: "Domicile" - Moon rules this sign
For general elections, avoid Scorpio and Capricorn.
"""
print_header("Example 7: Moon Sign Restrictions")
print("A) Avoid Moon in debility (Scorpio or Capricorn):")
results = (
ElectionalSearch(*MONTH_RANGE, DEFAULT_LOCATION)
.where(sign_not_in("Moon", ["Scorpio", "Capricorn"]))
.find_moments(max_results=5, step="day")
)
print_results(results, max_show=5)
print("\n" + "-" * 50)
print("\nB) Require Moon in dignity (Cancer or Taurus):")
results = (
ElectionalSearch(*QUARTER_RANGE, DEFAULT_LOCATION)
.where(sign_in("Moon", ["Cancer", "Taurus"]))
.find_moments(max_results=5, step="day")
)
print_results(results, max_show=5)
def example_8_moon_aspects():
"""
Example 8: Moon Aspects (Applying/Separating)
---------------------------------------------
The Moon's applying aspects show what's "coming" - very important
in electional work. Separating aspects show what's "past."
- Applying trine/sextile to Jupiter or Venus: Excellent
- Applying square/opposition to Mars or Saturn: Avoid
"""
print_header("Example 8: Moon Aspects")
print("A) Moon applying trine or sextile to Jupiter:")
results = (
ElectionalSearch(*MONTH_RANGE, DEFAULT_LOCATION)
.where(aspect_applying("Moon", "Jupiter", ["trine", "sextile"]))
.find_moments(max_results=5, step="4hour")
)
print_results(results, max_show=5)
print("\n" + "-" * 50)
print("\nB) Moon applying to Venus (any harmonious aspect):")
results = (
ElectionalSearch(*MONTH_RANGE, DEFAULT_LOCATION)
.where(aspect_applying("Moon", "Venus", ["conjunction", "trine", "sextile"]))
.find_moments(max_results=5, step="4hour")
)
print_results(results, max_show=5)
# =============================================================================
# PART 3: PLANETARY CONDITIONS
# =============================================================================
def example_9_retrograde():
"""
Example 9: Retrograde Avoidance
-------------------------------
Retrograde planets appear to move backward. Traditional electional
avoids starting things when key planets are retrograde:
- Mercury Rx: Communication, contracts, travel issues
- Venus Rx: Relationship, beauty, value issues
- Mars Rx: Action, competition, energy issues
"""
print_header("Example 9: Retrograde Avoidance")
print("Query: Mercury NOT retrograde")
print("(Important for contracts, communication, travel)")
print()
results = (
ElectionalSearch(*QUARTER_RANGE, DEFAULT_LOCATION)
.where(not_retrograde("Mercury"))
.find_moments(max_results=5, step="day")
)
print_results(results, max_show=5)
print("\n" + "-" * 50)
print("\nQuery: Both Mercury AND Venus NOT retrograde")
results = (
ElectionalSearch(*QUARTER_RANGE, DEFAULT_LOCATION)
.where(not_retrograde("Mercury"))
.where(not_retrograde("Venus"))
.find_moments(max_results=5, step="day")
)
print_results(results, max_show=5)
def example_10_dignity():
"""
Example 10: Dignity Requirements
--------------------------------
Planets in dignity are strengthened:
- Domicile/Ruler: Planet in the sign it rules
- Exaltation: Planet in sign where it's exalted
For elections involving a planet, having it dignified helps.
"""
print_header("Example 10: Dignity Requirements")
print("A) Venus dignified (in Taurus, Libra, or Pisces):")
results = (
ElectionalSearch(*QUARTER_RANGE, DEFAULT_LOCATION)
.where(is_dignified("Venus", ["ruler", "exaltation"]))
.find_moments(max_results=5, step="day")
)
print_results(results, max_show=5)
print("\n" + "-" * 50)
print("\nB) Mars NOT debilitated (not in Cancer or Libra):")
results = (
ElectionalSearch(*MONTH_RANGE, DEFAULT_LOCATION)
.where(not_debilitated("Mars"))
.find_moments(max_results=5, step="day")
)
print_results(results, max_show=5)
def example_11_combust():
"""
Example 11: Combust Planets
---------------------------
A planet within ~8.5° of the Sun is "combust" - hidden by the Sun's
light and weakened. Avoid elections where key planets are combust.
Exception: Cazimi (within 17') is extremely powerful, not weak.
"""
print_header("Example 11: Combust Planets")
print("Query: Moon NOT combust (more than 8.5° from Sun)")
print("(Combust Moon = hidden, weakened lunar energy)")
print()
results = (
ElectionalSearch(*SHORT_RANGE, DEFAULT_LOCATION)
.where(not_combust("Moon"))
.find_moments(max_results=5, step="day")
)
print_results(results, max_show=5)
# Show Sun-Moon distance
if results:
print("\nSun-Moon distances:")
for m in results[:3]:
moon = m.chart.get_object("Moon")
sun = m.chart.get_object("Sun")
diff = abs(moon.longitude - sun.longitude)
if diff > 180:
diff = 360 - diff
print(f" {m.datetime.strftime('%b %d')}: {diff:.1f}°")
def example_12_out_of_bounds():
"""
Example 12: Out of Bounds Planets
---------------------------------
Planets beyond the Sun's maximum declination (~23.4°) are "out of bounds."
OOB planets operate outside normal rules - can be genius or erratic.
Some electional traditions avoid OOB Moon; others seek it for
unconventional undertakings.
"""
print_header("Example 12: Out of Bounds Planets")
print("A) Moon NOT out of bounds (conventional energy):")
results = (
ElectionalSearch(*MONTH_RANGE, DEFAULT_LOCATION)
.where(not_out_of_bounds("Moon"))
.find_moments(max_results=5, step="day")
)
print_results(results, max_show=5)
print("\n" + "-" * 50)
print("\nB) Finding OUT OF BOUNDS Moon (unconventional energy):")
results = (
ElectionalSearch(*QUARTER_RANGE, DEFAULT_LOCATION)
.where(is_out_of_bounds("Moon"))
.find_moments(max_results=5, step="day")
)
print_results(results, max_show=5)
# =============================================================================
# PART 4: ASPECT CONDITIONS
# =============================================================================
def example_13_requiring_aspects():
"""
Example 13: Requiring Specific Aspects
--------------------------------------
You can require that two planets be in a specific aspect.
Applying aspects are usually more important than separating.
"""
print_header("Example 13: Requiring Specific Aspects")
print("A) Sun trine Jupiter (applying) - excellent for expansion:")
results = (
ElectionalSearch(*QUARTER_RANGE, DEFAULT_LOCATION)
.where(aspect_applying("Sun", "Jupiter", ["trine"]))
.find_moments(max_results=5, step="day")
)
print_results(results, max_show=5)
print("\n" + "-" * 50)
print("\nB) Venus conjunct or sextile Mars - passion/attraction:")
results = (
ElectionalSearch(*QUARTER_RANGE, DEFAULT_LOCATION)
.where(has_aspect("Venus", "Mars", ["conjunction", "sextile"]))
.find_moments(max_results=5, step="day")
)
print_results(results, max_show=5)
def example_14_avoiding_hard_aspects():
"""
Example 14: Avoiding Hard Aspects
---------------------------------
Hard aspects (squares and oppositions) bring tension and obstacles.
no_hard_aspect() checks that a planet has no applying hard aspects.
"""
print_header("Example 14: Avoiding Hard Aspects")
print("Query: Moon has NO applying squares or oppositions")
print()
results = (
ElectionalSearch(*SHORT_RANGE, DEFAULT_LOCATION)
.where(no_hard_aspect("Moon"))
.find_moments(max_results=5, step="4hour")
)
print_results(results, max_show=5)
def example_15_malefic_avoidance():
"""
Example 15: Malefic Avoidance (Mars/Saturn)
-------------------------------------------
Mars and Saturn are traditional "malefics" - they can bring
difficulties, delays, and conflict. no_malefic_aspect() specifically
checks for hard aspects from Mars or Saturn.
"""
print_header("Example 15: Malefic Avoidance")
print("Query: Moon has no hard aspects from Mars or Saturn")
print("(Avoids applying conjunction, square, opposition to malefics)")
print()
results = (
ElectionalSearch(*SHORT_RANGE, DEFAULT_LOCATION)
.where(no_malefic_aspect("Moon"))
.find_moments(max_results=5, step="4hour")
)
print_results(results, max_show=5)
def example_16_complex_aspect_combinations():
"""
Example 16: Complex Aspect Combinations
---------------------------------------
Combine aspect requirements with boolean logic for sophisticated
electional criteria.
"""
print_header("Example 16: Complex Aspect Combinations")
print("Query: Moon applying to Jupiter OR Venus (harmonious)")
print(" AND Moon has no hard aspects from Mars or Saturn")
print()
benefic_contact = any_of(
aspect_applying("Moon", "Jupiter", ["conjunction", "trine", "sextile"]),
aspect_applying("Moon", "Venus", ["conjunction", "trine", "sextile"]),
)
results = (
ElectionalSearch(*MONTH_RANGE, DEFAULT_LOCATION)
.where(benefic_contact)
.where(no_malefic_aspect("Moon"))
.find_moments(max_results=5, step="4hour")
)
print_results(results, max_show=5)
# =============================================================================
# PART 5: HOUSE & ANGLE CONDITIONS
# =============================================================================
def example_17_angular_planets():
"""
Example 17: Angular Planets
---------------------------
Angular houses (1, 4, 7, 10) are the most powerful positions.
Planets there have maximum influence. on_angle() checks for this.
"""
print_header("Example 17: Angular Planets")
print("A) Jupiter angular (in houses 1, 4, 7, or 10):")
results = (
ElectionalSearch(*MONTH_RANGE, DEFAULT_LOCATION)
.where(on_angle("Jupiter"))
.find_moments(max_results=5, step="hour")
)
print_results(results, max_show=5)
print("\n" + "-" * 50)
print("\nB) Moon angular:")
results = (
ElectionalSearch(*SHORT_RANGE, DEFAULT_LOCATION)
.where(on_angle("Moon"))
.find_moments(max_results=5, step="hour")
)
print_results(results, max_show=5)
def example_18_avoiding_difficult_houses():
"""
Example 18: Avoiding Difficult Houses
-------------------------------------
Houses 6, 8, and 12 are traditionally "difficult" houses associated
with illness, death, and hidden enemies. Avoid key planets there.
"""
print_header("Example 18: Avoiding Difficult Houses")
print("Query: Moon NOT in houses 6, 8, or 12")
print()
results = (
ElectionalSearch(*SHORT_RANGE, DEFAULT_LOCATION)
.where(not_in_house("Moon", [6, 8, 12]))
.find_moments(max_results=5, step="4hour")
)
print_results(results, max_show=5)
def example_19_benefics_in_good_houses():
"""
Example 19: Benefics in Good Houses
-----------------------------------
Jupiter and Venus are "benefics" - they bring good fortune.
Having them in prominent houses (1, 4, 7, 10, 11) strengthens
an election.
"""
print_header("Example 19: Benefics in Good Houses")
print("Query: Jupiter in houses 1, 4, 7, 10, or 11")
print(" OR Venus in houses 1, 4, 7, 10, or 11")
print()
good_houses = [1, 4, 7, 10, 11]
results = (
ElectionalSearch(*MONTH_RANGE, DEFAULT_LOCATION)
.where(
any_of(
in_house("Jupiter", good_houses),
in_house("Venus", good_houses),
)
)
.find_moments(max_results=5, step="hour")
)
print_results(results, max_show=5)
# =============================================================================
# PART 6: COMPOSITION & COMPLEX QUERIES
# =============================================================================
def example_20_and_logic():
"""
Example 20: AND Logic (all_of)
------------------------------
all_of() requires ALL conditions to be true.
This is equivalent to chaining .where() calls.
"""
print_header("Example 20: AND Logic (all_of)")
print("These two searches are equivalent:")
print()
print("A) Using chained .where() calls:")
results1 = (
ElectionalSearch(*SHORT_RANGE, DEFAULT_LOCATION)
.where(is_waxing())
.where(not_voc())
.where(not_retrograde("Mercury"))
.find_moments(max_results=3, step="day")
)
print(f" Found: {len(results1)} results")
print("\nB) Using all_of():")
combined = all_of(is_waxing(), not_voc(), not_retrograde("Mercury"))
results2 = (
ElectionalSearch(*SHORT_RANGE, DEFAULT_LOCATION)
.where(combined)
.find_moments(max_results=3, step="day")
)
print(f" Found: {len(results2)} results")
def example_21_or_logic():
"""
Example 21: OR Logic (any_of)
-----------------------------
any_of() requires AT LEAST ONE condition to be true.
"""
print_header("Example 21: OR Logic (any_of)")
print("Query: Moon in Cancer OR Moon in Taurus (dignity)")
print()
dignified_moon = any_of(
sign_in("Moon", ["Cancer"]), # Domicile
sign_in("Moon", ["Taurus"]), # Exaltation
)
results = (
ElectionalSearch(*QUARTER_RANGE, DEFAULT_LOCATION)
.where(dignified_moon)
.find_moments(max_results=5, step="day")
)
print_results(results, max_show=5)
def example_22_not_logic():
"""
Example 22: NOT Logic (not_)
----------------------------
not_() negates a condition. You can negate any predicate or
composed condition.
"""
print_header("Example 22: NOT Logic (not_)")
print("A) NOT waning = waxing:")
results = (
ElectionalSearch(*SHORT_RANGE, DEFAULT_LOCATION)
.where(not_(is_waning()))
.find_moments(max_results=3, step="day")
)
print(f" Found: {len(results)} results")
print("\nB) NOT (Moon in fire signs):")
fire_signs = sign_in("Moon", ["Aries", "Leo", "Sagittarius"])
results = (
ElectionalSearch(*SHORT_RANGE, DEFAULT_LOCATION)
.where(not_(fire_signs))
.find_moments(max_results=3, step="day")
)
print_results(results, max_show=3)
def example_23_nested_boolean():
"""
Example 23: Nested Boolean Expressions
--------------------------------------
Compose arbitrarily complex conditions by nesting all_of, any_of, not_.
"""
print_header("Example 23: Nested Boolean Expressions")
print("Query: (Moon trine Jupiter OR Moon sextile Venus)")
print(" AND NOT (Moon in Scorpio OR Moon in Capricorn)")
print(" AND Moon is waxing")
print()
# Build each piece
good_aspect = any_of(
aspect_applying("Moon", "Jupiter", ["trine"]),
aspect_applying("Moon", "Venus", ["sextile"]),
)
bad_sign = any_of(
sign_in("Moon", ["Scorpio"]),
sign_in("Moon", ["Capricorn"]),
)
# Combine
complex_condition = all_of(good_aspect, not_(bad_sign), is_waxing())
results = (
ElectionalSearch(*QUARTER_RANGE, DEFAULT_LOCATION)
.where(complex_condition)
.find_moments(max_results=5, step="4hour")
)
print_results(results, max_show=5)
def example_24_regulus_talisman():
"""
Example 24: The Reddit "Regulus Talisman" Query
-----------------------------------------------
This is inspired by the Reddit post that sparked this feature.
A Regulus talisman election requires many strict conditions:
1. Regulus applying conjunction to Ascendant OR Midheaven
2. Regulus NOT in applying square/opposition to any planet
3. Moon applying conjunction/trine/sextile to Regulus
4. Moon waxing
5. Moon NOT combust
6. Moon NOT in applying square/opposition to any planet
7. Moon NOT in detriment (Capricorn) or fall (Scorpio)
8. Moon NOT void of course
Note: Some conditions (like Regulus on exact Ascendant) require
Phase 2 optimization to search efficiently. This example shows
the Moon-focused conditions.
"""
print_header("Example 24: Reddit 'Regulus Talisman' Query (Moon Conditions)")
print("Strict traditional election criteria:")
print(" - Moon waxing")
print(" - Moon NOT void of course")
print(" - Moon NOT combust")
print(" - Moon NOT in Scorpio or Capricorn")
print(" - Moon has NO applying hard aspects")
print(" - Moon has NO hard aspects from Mars or Saturn")
print()
print("Searching 3 months...")
print()
results = (
ElectionalSearch(*QUARTER_RANGE, DEFAULT_LOCATION)
.where(is_waxing())
.where(not_voc())
.where(not_combust("Moon"))
.where(sign_not_in("Moon", ["Scorpio", "Capricorn"]))
.where(no_hard_aspect("Moon"))
.where(no_malefic_aspect("Moon"))
.find_moments(max_results=10, step="4hour")
)
print_results(results, max_show=10)
# =============================================================================
# PART 7: PRACTICAL ELECTIONS
# =============================================================================
def example_25_general_good_times():
"""
Example 25: General Good Times
------------------------------
A simple "generally good" election for any important undertaking.
"""
print_header("Example 25: General Good Times")
print("Criteria for generally auspicious times:")
print(" - Moon waxing")
print(" - Moon NOT void of course")
print(" - Moon NOT in difficult signs (Scorpio, Capricorn)")
print(" - Mercury NOT retrograde")
print()
results = (
ElectionalSearch(*MONTH_RANGE, DEFAULT_LOCATION)
.where(is_waxing())
.where(not_voc())
.where(sign_not_in("Moon", ["Scorpio", "Capricorn"]))
.where(not_retrograde("Mercury"))
.find_moments(max_results=10, step="4hour")
)
print_results(results, max_show=10)