Skip to content

Commit

Permalink
removed duplication of lsq-ellipse package and call it instead
Browse files Browse the repository at this point in the history
  • Loading branch information
kip-hart committed May 12, 2020
1 parent 64df77e commit fd54f43
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 73 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ All notable changes to this project will be documented in this file.
The format is based on `Keep a Changelog`_,
and this project adheres to `Semantic Versioning`_.

`Unreleased`_ - 2020-05-11
--------------------------
Changed
'''''''
- Ellipse of best fit method calls the `lsq-ellipse`_ package.

`1.1.2`_ - 2019-11-07
---------------------
Fixed
Expand Down Expand Up @@ -65,4 +71,5 @@ Added
.. _`1.0.0`: https://github.com/kip-hart/MicroStructPy/releases/tag/v1.0.0

.. _`Keep a Changelog`: https://keepachangelog.com/en/1.0.0/
.. _`Semantic Versioning`: https://semver.org/spec/v2.0.0.html
.. _`lsq-ellipse`: https://pypi.org/project/lsq-ellipse
.. _`Semantic Versioning`: https://semver.org/spec/v2.0.0.html
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ pyvoro-mmalahe==1.3.3
scipy==1.3.1
xmltodict==0.12.0
tox==3.14.0
lsq-ellipse==2.0.1
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def find_version(*fname):
'aabbtree',
'matplotlib>=2.2.0,<3.1.0',
'pybind11', # must come before meshpy for successful install
'lsq-ellipse',
'meshpy>=2018.2.1',
'numpy>=1.13.0',
'pyquaternion',
Expand Down
68 changes: 0 additions & 68 deletions src/microstructpy/geometry/_ellipse_best_fit.py

This file was deleted.

11 changes: 7 additions & 4 deletions src/microstructpy/geometry/ellipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# --------------------------------------------------------------------------- #
from __future__ import division

import ellipses as lsqel
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import patches
Expand Down Expand Up @@ -169,9 +170,8 @@ def best_fit(self, points):
r"""Find ellipse of best fit for points
This function computes the ellipse of best fit for a set of points.
It is heavily adapted from the `least-squares-ellipse-fitting`_
repository on GitHub. This repository implements a published fitting
algorithm in Python. [#halir]_
It calls the `least-squares-ellipse-fitting`_ package, which implements
a published fitting algorithm in Python. [#halir]_
The current instance of the class is used as an initial guess for
the ellipse of best fit. Since an ellipse can be expressed multiple
Expand All @@ -197,7 +197,10 @@ def best_fit(self, points):
pt_cen = pts.mean(axis=0)
pts -= pt_cen.reshape(1, -1)

width, height, phi, xc, yc = _best_fit(pts, self)
reg = lsqel.LsqEllipse().fit(pts)
center, width, height, phi = reg.as_parameters()
xc, yc = center

xc += pt_cen[0]
yc += pt_cen[1]

Expand Down

0 comments on commit fd54f43

Please sign in to comment.