Pendant Pendant Sum Fieldmark Comparison


1. Comparison of Pendant-Pendant-Sums to Other Fieldmarks:

Code
#=======================================================
# INITIALIZE
# Read in the Fieldmark and its associated dataframes
#=======================================================
import plotly
import pandas as pd
import qollqa_chuspa as qc
import utils_khipu as ukhipu

from fieldmark_ascher_pendant_pendant_sum import FieldmarkPendantPendantSum
aFieldmark = FieldmarkPendantPendantSum()
khipu_df = aFieldmark.dataframes[0].dataframe
sum_cord_df = aFieldmark.dataframes[1].dataframe

(khipu_dict, all_khipus) = qc.fetch_khipus()

# Initialize plotly
plotly.offline.init_notebook_mode(connected = False);

ppsum_df = pd.read_csv(f"{ukhipu.fieldmarks_data_directory()}/CSV/pendant_pendant_sum_relation.csv")
pps_khipus = sorted(list(set(list(ppsum_df.kfg_name.values))))
ascher_sum_relations_df = pd.read_csv(f"{ukhipu.fieldmarks_data_directory()}/CSV/ascher_sums_overview.csv")

2. Comparing the Three Ascher Sum Relationships:

There are three Ascher pendant sum relationships - Pendant Pendant Sums, Pendant Pendant By Color Sums and Indexed Pendant Sums. Do these relationships correlate in some fashion?

Code
import utils_loom as uloom
pendant_pendant_sums_vec = list(ascher_sum_relations_df.num_pendant_pendant_sums.values)
pendant_pendant_color_sums_vec = list(ascher_sum_relations_df.num_colored_pendant_sums.values)
indexed_pendant_sums_vec = list(ascher_sum_relations_df.num_indexed_pendant_sums.values)

pps_ppsc = uloom.degrees_between(pendant_pendant_sums_vec, pendant_pendant_color_sums_vec)
pps_ips = uloom.degrees_between(pendant_pendant_sums_vec, indexed_pendant_sums_vec)
ips_ppsc = uloom.degrees_between(indexed_pendant_sums_vec, pendant_pendant_color_sums_vec)

print(f"Degrees between Pendant Pendant_Sums and Pendant Pendant_Color_Sums is {pps_ppsc:.0f}°")
print(f"Degrees between Pendant Pendant_Sums and Indexed Pendant_Sums is {pps_ips:.0f}°")
print(f"Degrees between Indexed Pendant_Sums and Pendant Pendant_Color_Sums is {ips_ppsc:.0f}°")
Degrees between Pendant Pendant_Sums and Pendant Pendant_Color_Sums is 40°
Degrees between Pendant Pendant_Sums and Indexed Pendant_Sums is 41°
Degrees between Indexed Pendant_Sums and Pendant Pendant_Color_Sums is 43°

Answer: Not much.

3. Sum/Summand Cords vs All Pendants:

What percentage of a khipu is sum, or summand cords? Astonishingly, AS069 is quite high in this list.

Code
import warnings
warnings.filterwarnings("ignore")

interesting_khipus_df = khipu_df[khipu_df.num_sum_cords > 0]
def calculate_num_pendant_sum_cords(aKhipu, relation_df):
    sum_cords = []
    summand_cords = []
    for cord_pos in khipu_relations.cord_index.values:
        sum_cords +=  cords_from_sum_string(aKhipu, cord_pos) 
    for sum_string in khipu_relations.summand_string.values:
        summand_cords += cords_from_sum_string(aKhipu, sum_string) 
    return (sum_cords, summand_cords)

def cords_from_sum_string(aKhipu, sum_string):
    # sum_string = "[27, 0]:6 +[27, 1]:7 "
    # Be on guard for malformed strings
    try:
        if "?" in sum_string: 
            cords = [] # Malformed sum string
        else:
            cord_reps = [aString for aString in sum_string.strip().split("+")] 
            cords = [cord_from_rep(aKhipu, aRep) for aRep in cord_reps]
    except:
        cords = []
    return cords

def cord_from_rep(aKhipu, cord_rep):
    # sum_string = "'DB-W'@[27, 0]:6  "
    cord_rep = cord_rep.split(":")[0].strip() if ":" in cord_rep else cord_rep
    cord_rep = cord_rep.split("@")[1].strip() if "@" in cord_rep else cord_rep
    def cluster_from_rep(aRep): return int(aRep.split(",")[0].strip().replace("[","")) 
    def cord_from_rep(aRep): return int(aRep.split(",")[1].strip().replace("]",""))
    cluster = aKhipu[cluster_from_rep(cord_rep)]
    cord = cluster[cord_from_rep(cord_rep)]
    return cord
    
pendant_sum_cord_ratio_df = pd.DataFrame(columns = ['name', 'num_sum_cords', 'num_summand_cords', 'num_summation_cords', 'num_nonzero_pendants', 'ratio_sums_to_pendants'])
for aKFG_Name in list(interesting_khipus_df.kfg_name.values):
    aKhipu = khipu_dict[aKFG_Name]
    num_nonzero_pendants = len([aCord for aCord in aKhipu.pendant_cords() if aCord.knotted_value > 0])
    khipu_relations = sum_cord_df[sum_cord_df.kfg_name == aKFG_Name]
    (sum_cords, summand_cords) = calculate_num_pendant_sum_cords(aKhipu, khipu_relations)
    num_sum_cords = len(set(sum_cords))
    num_summand_cords = len(set(summand_cords))
    num_summation_cords = len(set(sum_cords + summand_cords))
    ratio_sums_to_pendants = round(100.0*num_summation_cords/num_nonzero_pendants) if num_nonzero_pendants else 0
    record = {'kfg_name':aKFG_Name, 
              'num_sum_cords':num_sum_cords, 
              'num_summand_cords':num_summand_cords, 
              'num_summation_cords':num_summation_cords, 
              'num_nonzero_pendants':num_nonzero_pendants, 
              'ratio_sums_to_pendants': ratio_sums_to_pendants}
    pendant_sum_cord_ratio_df = pd.concat([pendant_sum_cord_ratio_df, pd.DataFrame([record])], ignore_index=True)

csv_file = f"{ukhipu.fieldmarks_data_directory()}/CSV/pendant_pendant_sum_ratios.csv"
pendant_sum_cord_ratio_df.to_csv(csv_file)
Code
import plotly.express as px
fig = (px.scatter(pendant_sum_cord_ratio_df, x="num_nonzero_pendants", y="num_summation_cords", 
                 labels={"num_nonzero_pendants": f"Number of Non-Zero Pendants", 
                         "num_summation_cords": "Number of Summation (Sums or Summands) Pendants", 
                         'num_sum_cords':"# Sum Cords", 'num_summand_cords':"# Summand Cords", 'ratio_sums_to_pendants':"% of Summation Cords in Pendants"},
                 hover_data=['name', 'num_sum_cords', 'num_summand_cords', 'num_summation_cords', 'num_nonzero_pendants', 'ratio_sums_to_pendants'], 
                 title="<b>Sum Pendants vs All Pendants</b> - <i>Hover to View Khipu/Cord Info</i>",
                 trendline="ols",
                 width=944, height=944)
        .update_layout(showlegend=False)
        .show()
      )

Roughly 70% of a khipu’s non-zero pendants are involved in being a sum or a summand. There is a strong linear trend line (R2=0.78) for the relationship between number of pendant cords, and those involved as sums or summands.

4. Conclusions:

  • There is little to no pattern synchronicity in cords between the three sum relationships.
    • Degrees between Pendant Pendant_Sums and Pendant Pendant_Color_Sums is 40°
    • Degrees between Pendant Pendant_Sums and Indexed Pendant_Sums is 41°
    • Degrees between Indexed Pendant_Sums and Pendant Pendant_Color_Sums is 43°
  • Roughly 70% of a khipu’s non-zero pendants are involved in being a sum or a summand. There is a strong linear trend line (R2=0.36) for the relationship between number of pendant cords, and those involved as sums or summands.