### Install shapesimilarity from source Source: https://pypi.org/project/shapesimilarity/1.0.0 Install the shapesimilarity package by cloning the source code repository and then installing it locally. This is useful for development or if you need the latest unreleased version. ```bash $ git clone https://github.com/nelsonwenner/shape-similarity.git $ python -m pip install . ``` -------------------------------- ### Install shapesimilarity with pip Source: https://pypi.org/project/shapesimilarity/1.0.0 Install the shapesimilarity package using pip. This is the recommended method for most users. ```bash $ python -m pip install shapesimilarity ``` -------------------------------- ### Run shapesimilarity tests Source: https://pypi.org/project/shapesimilarity/1.0.0 Install pytest and run the package's tests to ensure it is functioning correctly after installation. ```bash $ python -m pip install pytest $ python -m pytest ``` -------------------------------- ### Calculate Shape Similarity Source: https://pypi.org/project/shapesimilarity Calculate the similarity between two shapes using the shapesimilarity package. This example visualizes the shapes and their calculated similarity. ```python from shapesimilarity import shape_similarity import matplotlib.pyplot as plt import numpy as np x = np.linspace(1, -1, num=200) y1 = 2*x**2 + 1 y2 = 2*x**2 + 2 shape1 = np.column_stack((x, y1)) shape2 = np.column_stack((x, y2)) similarity = shape_similarity(shape1, shape2) plt.plot(shape1[:,0], shape1[:,1], linewidth=2.0) plt.plot(shape2[:,0], shape2[:,1], linewidth=2.0) plt.title(f'Shape similarity is: {similarity}', fontsize=14, fontweight='bold') plt.show() ``` -------------------------------- ### Customize shape_similarity function Source: https://pypi.org/project/shapesimilarity Customize the shape_similarity function by adjusting rotation correction and accuracy. Increasing rotation increases accuracy but also computation time. ```python # disable rotation correction entirely shape_similarity(shape1, shape2, checkRotation=False) # higher accuracy, but slower shape_similarity(shape1, shape2, rotation=30) ``` -------------------------------- ### Calculate and visualize shape similarity Source: https://pypi.org/project/shapesimilarity/1.0.0 Calculate the similarity between two shapes defined as NumPy arrays and visualize them using Matplotlib. Ensure shapes are preprocessed and formatted correctly. ```python from shapesimilarity import shape_similarity import matplotlib.pyplot as plt import numpy as np x = np.linspace(1, -1, num=200) y1 = 2*x**2 + 1 y2 = 2*x**2 + 2 shape1 = np.column_stack((x, y1)) shape2 = np.column_stack((x, y2)) similarity = shape_similarity(shape1, shape2) plt.plot(shape1[:,0], shape1[:,1], linewidth=2.0) plt.plot(shape2[:,0], shape2[:,1], linewidth=2.0) plt.title(f'Shape similarity is: {similarity}', fontsize=14, fontweight='bold') plt.show() ``` -------------------------------- ### Customize shape_similarity function parameters Source: https://pypi.org/project/shapesimilarity/1.0.0 Adjust the precision and rotation correction of the shape_similarity function. Increasing the rotation parameter improves accuracy but increases computation time. Disabling checkRotation can be done for specific use cases. ```python # disable rotation correction entirely shape_similarity(shape1, shape2, checkRotation=False) # higher accuracy, but slower shape_similarity(shape1, shape2, rotation=30) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.