<jupyter_start><jupyter_text>Klein's curveDemonstration of the functionality of CyclePainter. For more information see 3.3 of the thesis.<jupyter_code># Initialize jupyter notebook. Calling twice allegedly avoids a bug
%matplotlib notebook
%matplotlib notebook 

from cyclepainter import *
# Defining polynomial of Klein's curve
k.<rho>=CyclotomicField(3)
A2.<z,w>=AffineSpace(k,2)
klein = w^7-(z-1)*(z-rho)^2*(z-rho^2)^4
# Hand-picked cohomology basis
diffs = [
    1/w^5,
    1/w^6,
    1/w^3
]
# Automorphism of Klein's curve
s = lambda z, w: (rho^2*z, rho^2*(z-1)*(z-rho)*(z - rho^2)^2/w^3)<jupyter_output><empty_output><jupyter_text><jupyter_code># Define the CyclePainter object.
# kappa is the radius of avoidance of branch points used in abelfunctions.
cp = CyclePainter(klein, kappa=2./5.)
# Start the interactive plot.
#
# Workflow:
#    - to begin drawing a new path, click on "New path". 
#    - By clicking on the canvas, the path can be now defined. It is recommended to avoid the kappa 
#      circles around branch points. 
#    - Once you are satisfied with the path, click on "Finish path". The last point will be automatically
#.     connected to the monodromy point (denoted by star). Every path must be starting and ending in the 
#.     monodromy point.
#    - The radio-buttons on the right indicate the starting sheet of the path. This may be changed at any point.

# Go ahead now and define your own path by the above steps. Once "Finish path" button is clicked,
#     you may execute the next cell.

cp.start()
# To save a path for processing (possible only AFTER clicking "Finish path"), you need to call
p = cp.save_path('my_little_path')

# A unique name needs to be given.
# If you lose reference the path variable, it is now accessibly by its name
_ = cp.get_path('my_little_path')
# If you want to clean the canvas, you can run
cp.clear_canvas()
# And if you want to plot a saved path again
cp.plot_path('my_little_path')
# You may take a look at path's defining projection points and starting sheet
_, _ = p.starting_sheet, p.projection_points
# Or you may need to access the paths x/y values at some time t \in [0, 1]
p.get_x(0.42)
p.get_y(0.42) # (these are ordered)
# You can integrate an one-form over the path
p.integrate(diffs[0])
# Or find the intersection numbers with other paths
p.intersection_number(p)

# Note: in extreme cases, I have encountered errors in the intersections numbers. Take with a grain of salt.
# We can also go back to cyclepainter object to find intersection matrix of multiple paths
cp.intersection_matrix(['my_little_path', 'my_little_path'])
# You can also apply an automorphism on the path (scroll up back to the plot to see it)
p.apply_automorphism(s)

# NOTE:
#   - the monodromy point will be sent to a different place, the ordering of the sheets is hence unreliable
#   - this function is meant for investigation only, to use the path, one should manually redraw it.
# To save all of the paths into a file for future use
cp.pickle_paths('pickled_paths_file.pickle')
# This created a new file in the working directory. To load paths from such a file
cp.load_paths('pickled_paths_file.pickle')<jupyter_output><empty_output><jupyter_text><jupyter_code># Load pre-pickled paths for the Klein's curve
cp.load_paths('klein_curve_paths.pickle')
# These paths are now available
cp.saved_paths()
# I'll go ahead and open a new plot for visibility. Please go ahead and close the first one (right-top corner button)
cp.start()
# this is, by the way, how one of the monodromy paths looks like
cp.branch_points[0].show_permutation_path()
# and this is the first of the a-cycles we just loaded
cp.plot_path('a1')
# Verify the intersection matrix
cp.intersection_matrix(['a1', 'a2', 'a3', 'b1', 'b2', 'b3'])
# Good to go. Calculate the period matrix with this homology basis
a_cycles = ['a1', 'a2', 'a3']
b_cycles = ['b1', 'b2', 'b3']

# cp.period_matrix(a_cycles, b_cycles, diffs)
# And finally, the highly-symmetric Riemann matrix
rm = cp.riemann_matrix(a_cycles, b_cycles, diffs)
np.round(rm, 9)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09424724602203183, 'fraction_numerical': 0.01175030599755202, 'mean_word_length': 4.484563758389262, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '54184', 'license': 'MIT', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1289, 'n_words': 536, 'path': "Klein's curve.ipynb", 'repo_name': 'DisneyHogg/abelfunctions-cyclepainter', 'size': '4085'}