From 4d6f3da35f56b1b804d2d3e91e7c0fb8c20d787c Mon Sep 17 00:00:00 2001 From: Andrew Walker Date: Wed, 25 Feb 2026 09:05:11 +0000 Subject: [PATCH 1/5] Specify __version__ in package We use this dynamically in the spynx config for documentation now too. --- docs/source/conf.py | 3 +-- src/premlike/__init__.py | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 83e4451..2c1de4d 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -21,8 +21,7 @@ copyright = f'2026, {authors}' author = authors -#release = premlike.__version__ -release = "0.1.0-alpha1" +release = premlike.__version__ # -- General configuration diff --git a/src/premlike/__init__.py b/src/premlike/__init__.py index c759d59..b4a810e 100644 --- a/src/premlike/__init__.py +++ b/src/premlike/__init__.py @@ -4,4 +4,5 @@ from .const import R_EARTH from .PREM import PREM -__all__ = ["OneDModel", "R_EARTH", "PREM", "tabulate_model"] \ No newline at end of file +__all__ = ["OneDModel", "R_EARTH", "PREM", "tabulate_model"] +__version__ = "0.1.0-alpha1" \ No newline at end of file From d6548265143ceb8707b12e74af57f987d6ab0fdf Mon Sep 17 00:00:00 2001 From: Andrew Walker Date: Wed, 25 Feb 2026 09:13:37 +0000 Subject: [PATCH 2/5] Add some text to the first page --- docs/source/index.rst | 15 ++++++++++++++- docs/source/usage.rst | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 docs/source/usage.rst diff --git a/docs/source/index.rst b/docs/source/index.rst index a9ceb30..d2610bb 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -1,4 +1,17 @@ PremLike documentation ====================== -TBC \ No newline at end of file +Work with models of the Earth that are parameterized +like PREM. + +.. note:: + + This project is under active development. The api + is likely to change without warning. + +Contents +-------- + +.. toctree:: + + usage \ No newline at end of file diff --git a/docs/source/usage.rst b/docs/source/usage.rst new file mode 100644 index 0000000..d57e9a4 --- /dev/null +++ b/docs/source/usage.rst @@ -0,0 +1,4 @@ +Usage +===== + +Some words need to go here \ No newline at end of file From b33d6bf5cce09cf512ca0e169e6b2ea9ea4dada1 Mon Sep 17 00:00:00 2001 From: Andrew Walker Date: Wed, 25 Feb 2026 15:50:26 +0000 Subject: [PATCH 3/5] Add documentation for api and theory Framework not content --- docs/source/api.rst | 37 +++++++++++++++++++++++++++++++++++++ docs/source/index.rst | 3 ++- docs/source/theory.rst | 10 ++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 docs/source/api.rst create mode 100644 docs/source/theory.rst diff --git a/docs/source/api.rst b/docs/source/api.rst new file mode 100644 index 0000000..8967542 --- /dev/null +++ b/docs/source/api.rst @@ -0,0 +1,37 @@ +API documentation +================= + +This is a reference covering public API for PremLike. + +Modules +------- + +`const` +^^^^^^^ + +.. automodule:: premlike.const + :members: + +`earth_model` +^^^^^^^^^^^^^ + +.. automodule:: premlike.earth_model + :members: + +`peice_poly` +^^^^^^^^^^^^ + +.. automodule:: premlike.peice_poly + :members: + +`physics` +^^^^^^^^^ + +.. automodule:: premlike.physics + :members: + +`PREM` +^^^^^^ + +.. automodule:: premlike.PREM + :members: \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst index d2610bb..f97e442 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -14,4 +14,5 @@ Contents .. toctree:: - usage \ No newline at end of file + usage + api \ No newline at end of file diff --git a/docs/source/theory.rst b/docs/source/theory.rst new file mode 100644 index 0000000..f737984 --- /dev/null +++ b/docs/source/theory.rst @@ -0,0 +1,10 @@ +Theory in PremLike +================== + +I need to write about the piecewise polynomials. To +do this I'll need LaTeX maths: + +.. math:: + y = ax^2 + b + +or math:`y = ax^2`. \ No newline at end of file From 904ee426e13bd66d9476c17b82e1af01e5fc5420 Mon Sep 17 00:00:00 2001 From: Andrew Walker Date: Fri, 27 Feb 2026 16:33:17 +0000 Subject: [PATCH 4/5] Fix spelling of piecewise Incorrect spelling in documentation, class name and module name. I think this is fixed in all places. --- docs/source/api.rst | 4 +- docs/source/index.rst | 3 +- src/premlike/earth_model.py | 2 +- src/premlike/physics.py | 2 +- src/premlike/{peice_poly.py => piece_poly.py} | 14 +++--- ...{test_peice_poly.py => test_piece_poly.py} | 46 +++++++++---------- 6 files changed, 36 insertions(+), 35 deletions(-) rename src/premlike/{peice_poly.py => piece_poly.py} (97%) rename tests/{test_peice_poly.py => test_piece_poly.py} (91%) diff --git a/docs/source/api.rst b/docs/source/api.rst index 8967542..b7d62e6 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -18,10 +18,10 @@ Modules .. automodule:: premlike.earth_model :members: -`peice_poly` +`piece_poly` ^^^^^^^^^^^^ -.. automodule:: premlike.peice_poly +.. automodule:: premlike.piece_poly :members: `physics` diff --git a/docs/source/index.rst b/docs/source/index.rst index f97e442..7e0996c 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -15,4 +15,5 @@ Contents .. toctree:: usage - api \ No newline at end of file + api + theory \ No newline at end of file diff --git a/src/premlike/earth_model.py b/src/premlike/earth_model.py index 2213fbb..440b4e4 100644 --- a/src/premlike/earth_model.py +++ b/src/premlike/earth_model.py @@ -9,7 +9,7 @@ import numpy as np from .const import R_EARTH -from .peice_poly import PeicewisePolynomial as PP +from .piece_poly import PiecewisePolynomial as PP from .physics import ( calculate_bulk_modulus, calculate_density, diff --git a/src/premlike/physics.py b/src/premlike/physics.py index accb818..01879c3 100644 --- a/src/premlike/physics.py +++ b/src/premlike/physics.py @@ -1,7 +1,7 @@ import numpy as np from .const import G, R_EARTH -from .peice_poly import PeicewisePolynomial as PP +from .piece_poly import PiecewisePolynomial as PP def calculate_vs( diff --git a/src/premlike/peice_poly.py b/src/premlike/piece_poly.py similarity index 97% rename from src/premlike/peice_poly.py rename to src/premlike/piece_poly.py index 5fe106c..7a65f22 100644 --- a/src/premlike/peice_poly.py +++ b/src/premlike/piece_poly.py @@ -1,16 +1,16 @@ #!/usr/bin/env python # coding=utf8 """ -Peicewise polynomials like PREM +Piecewise polynomials like PREM """ import numpy as np -class PeicewisePolynomial(object): +class PiecewisePolynomial(object): """ - Peicewise Polynomials a different way + Piecewise Polynomials a different way The SciPy PPoly class defines a function from polynomials with coefficents c and breakpoints x @@ -137,7 +137,7 @@ def derivative(self): deriv_neg_coeffs[seg, i + 1] = ( -1 * self.negative_coeffs[seg, i] * i ) - deriv = PeicewisePolynomial(deriv_coeffs, deriv_breakpoints, deriv_neg_coeffs) + deriv = PiecewisePolynomial(deriv_coeffs, deriv_breakpoints, deriv_neg_coeffs) return deriv def antiderivative(self): @@ -166,7 +166,7 @@ def antiderivative(self): antideriv_neg_coeffs[seg, i - 1] = ( -1 * self.negative_coeffs[seg, i] / (i - 1) ) - antideriv = PeicewisePolynomial( + antideriv = PiecewisePolynomial( antideriv_coeffs, antideriv_breakpoints, antideriv_neg_coeffs ) return antideriv @@ -213,7 +213,7 @@ def integrating_poly(self): # add all the other segments if bpi > 0: ip_coeffs[bpi, 0] = ip_coeffs[bpi, 0] + antiderivative.integrate(0, bp) - return PeicewisePolynomial(ip_coeffs, antiderivative.breakpoints) + return PiecewisePolynomial(ip_coeffs, antiderivative.breakpoints) def mult(self, other): # FIXME - for this approach brakepoints need to be same place too @@ -301,7 +301,7 @@ def mult(self, other): # TODO: handle non-overlapping breakpoints (first chop the # segments). Also implement do poly * const etc. - mult_poly = PeicewisePolynomial( + mult_poly = PiecewisePolynomial( mult_coefs, mult_breakpoints, mult_negative_coefs ) return mult_poly diff --git a/tests/test_peice_poly.py b/tests/test_piece_poly.py similarity index 91% rename from tests/test_peice_poly.py rename to tests/test_piece_poly.py index 1ab18ad..667fec8 100644 --- a/tests/test_peice_poly.py +++ b/tests/test_piece_poly.py @@ -1,18 +1,18 @@ """ -Test cases for PeicewisePolynomial class +Test cases for PiecewisePolynomial class """ import numpy as np import numpy.testing as npt -import premlike.peice_poly as pp +import premlike.piece_poly as pp def test_constant(): """ Check that a constant function gives allways gives its value """ - poly = pp.PeicewisePolynomial(np.array([[2.0], [2.0]]), + poly = pp.PiecewisePolynomial(np.array([[2.0], [2.0]]), np.array([0.0, 0.5, 1.0])) assert poly(0.0) == 2.0 assert poly(0.25) == 2.0 @@ -36,7 +36,7 @@ def test_quadratic(): """ Check that a quadratic function gives the correct value """ - poly = pp.PeicewisePolynomial(np.array([[0.0, 0.0, 1.0], [0.0, 0.0, 1.0]]), + poly = pp.PiecewisePolynomial(np.array([[0.0, 0.0, 1.0], [0.0, 0.0, 1.0]]), np.array([0.0, 0.5, 1.0])) assert poly(0.0) == 0.0 assert poly(0.25) == 0.25**2 @@ -60,7 +60,7 @@ def test_one_over_x(): Check that a 1/x function gives the correct value using a quadratic for x less than 0.5 """ - poly = pp.PeicewisePolynomial(np.array([[0.0, 0.0, 1.0], [0.0, 0.0, 0.0]]), + poly = pp.PiecewisePolynomial(np.array([[0.0, 0.0, 1.0], [0.0, 0.0, 0.0]]), np.array([0.0, 0.5, 1.0]), c_neg=np.array([[0.0, 0.0], [0.0, 1.0]])) assert poly(0.0) == 0.0 @@ -81,9 +81,9 @@ def test_one_over_x(): def test_step(): """ - Check that two peicewise constants give the right values + Check that two piecewise constants give the right values """ - poly = pp.PeicewisePolynomial(np.array([[2.0], [20.0]]), + poly = pp.PiecewisePolynomial(np.array([[2.0], [20.0]]), np.array([0.0, 0.5, 1.0])) assert poly(0.0) == 2.0 assert poly(0.25) == 2.0 @@ -117,7 +117,7 @@ def test_deriv(): And we can multiply everything by 10 and split the polynomial. """ - poly = pp.PeicewisePolynomial(np.array([[4.0, 3.0, 2.0], + poly = pp.PiecewisePolynomial(np.array([[4.0, 3.0, 2.0], [40.0, 30.0, 20.0]]), np.array([0.0, 2.0, 4.0])) expected_deriv_coefs = np.array([[3.0, 4.0], [30.0, 40.0]]) @@ -147,7 +147,7 @@ def test_recip_deriv(): And we can multiply everything by 10 and split the polynomial. """ - poly = pp.PeicewisePolynomial(np.array([[3.0, 4.0], + poly = pp.PiecewisePolynomial(np.array([[3.0, 4.0], [30.0, 40.0]]), np.array([0.0, 2.0, 4.0]), c_neg=np.array([[0.0, 2.0, 3.0], @@ -172,7 +172,7 @@ def test_antideriv(): And we can multiply everything by 10 and split the polynomial. """ - poly = pp.PeicewisePolynomial(np.array([[4.0, 3.0, 2.0], + poly = pp.PiecewisePolynomial(np.array([[4.0, 3.0, 2.0], [40.0, 30.0, 20.0]]), np.array([0.0, 2.0, 4.0])) expected_antideriv_coefs = np.array([[0.0, 4.0, 3.0/2.0, 2.0/3.0], @@ -191,7 +191,7 @@ def test_recip_antideriv(): And we can multiply everything by 10 and split the polynomial. """ - poly = pp.PeicewisePolynomial(np.array([[4.0], + poly = pp.PiecewisePolynomial(np.array([[4.0], [40.0]]), np.array([0.0, 2.0, 4.0]), c_neg=np.array([[0.0, 0.0, -2.0, -6.0], @@ -216,7 +216,7 @@ def test_log_deriv_int(): And we can multiply everything by 10 and split the polynomial. """ - poly = pp.PeicewisePolynomial(np.array([[3.0, 4.0], + poly = pp.PiecewisePolynomial(np.array([[3.0, 4.0], [30.0, 40.0]]), np.array([0.0, 2.0, 4.0]), c_neg=np.array([[5.0, 2.0, 3.0], @@ -251,7 +251,7 @@ def test_integrate(): And we can multiply everything by 10 and split the polynomial with addition over breakpoints. """ - poly = pp.PeicewisePolynomial(np.array([[4.0, 3.0, 2.0], + poly = pp.PiecewisePolynomial(np.array([[4.0, 3.0, 2.0], [40.0, 30.0, 20.0]]), np.array([0.0, 2.0, 4.0])) antideriv = poly.antiderivative() @@ -284,13 +284,13 @@ def test_mult(): and we split this polynomial in two to excercise the breakpoint checking. """ - poly1 = pp.PeicewisePolynomial(np.array([[4.0, 3.0, 2.0], + poly1 = pp.PiecewisePolynomial(np.array([[4.0, 3.0, 2.0], [4.0, 3.0, 2.0]]), np.array([0.0, 2.0, 4.0])) - poly2 = pp.PeicewisePolynomial(np.array([[1.0, 2.0, 4.0], + poly2 = pp.PiecewisePolynomial(np.array([[1.0, 2.0, 4.0], [1.0, 2.0, 4.0]]), np.array([0.0, 2.0, 4.0])) - expect_poly_mult = pp.PeicewisePolynomial( + expect_poly_mult = pp.PiecewisePolynomial( np.array([[4.0, 11.0, 24.0, 16.0, 8.0], [4.0, 11.0, 24.0, 16.0, 8.0]]), np.array([0.0, 2.0, 4.0])) @@ -308,17 +308,17 @@ def test_mult2(): breakpoint checking. Also check that order does not matter and we can square both polynomials """ - poly1 = pp.PeicewisePolynomial(np.array([[4.0, 3.0, 2.0], + poly1 = pp.PiecewisePolynomial(np.array([[4.0, 3.0, 2.0], [4.0, 3.0, 2.0]]), np.array([0.0, 2.0, 4.0]), np.array([[0.0, 3.0, 4.0], [0.0, 3.0, 4.0]])) - poly2 = pp.PeicewisePolynomial(np.array([[1.0, 2.0, 4.0], + poly2 = pp.PiecewisePolynomial(np.array([[1.0, 2.0, 4.0], [1.0, 2.0, 4.0]]), np.array([0.0, 2.0, 4.0]), np.array([[0.0, 0.0, 2.0], [0.0, 0.0, 2.0]])) - expect_poly_mult = pp.PeicewisePolynomial( + expect_poly_mult = pp.PiecewisePolynomial( np.array([[30.0, 23.0, 24.0, 16.0, 8.0], [30.0, 23.0, 24.0, 16.0, 8.0]]), np.array([0.0, 2.0, 4.0]), @@ -334,7 +334,7 @@ def test_mult2(): npt.assert_allclose(calc_poly_mult.negative_coeffs, expect_poly_mult.negative_coeffs) # Square poly 1 - expect_poly_mult = pp.PeicewisePolynomial( + expect_poly_mult = pp.PiecewisePolynomial( np.array([[50.0, 36.0, 25.0, 12.0, 4.0], [50.0, 36.0, 25.0, 12.0, 4.0]]), np.array([0.0, 2.0, 4.0]), @@ -354,15 +354,15 @@ def test_mult3(): and we split the polynomials in two to excercise the breakpoint checking. Also check that order does not matter """ - poly1 = pp.PeicewisePolynomial(np.array([[4.0, 3.0, 2.0], + poly1 = pp.PiecewisePolynomial(np.array([[4.0, 3.0, 2.0], [4.0, 3.0, 2.0]]), np.array([0.0, 2.0, 4.0]), np.array([[0.0, 3.0, 4.0], [0.0, 3.0, 4.0]])) - poly2 = pp.PeicewisePolynomial(np.array([[1.0, 2.0, 4.0], + poly2 = pp.PiecewisePolynomial(np.array([[1.0, 2.0, 4.0], [1.0, 2.0, 4.0]]), np.array([0.0, 2.0, 4.0])) - expect_poly_mult = pp.PeicewisePolynomial( + expect_poly_mult = pp.PiecewisePolynomial( np.array([[26.0, 23.0, 24.0, 16.0, 8.0], [26.0, 23.0, 24.0, 16.0, 8.0]]), np.array([0.0, 2.0, 4.0]), From 8f8ff3cdb3d34f679bf07010ed53c758cba9d083 Mon Sep 17 00:00:00 2001 From: Andrew Walker Date: Fri, 27 Feb 2026 16:37:17 +0000 Subject: [PATCH 5/5] Fix version string in __init__ --- src/premlike/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/premlike/__init__.py b/src/premlike/__init__.py index b4a810e..4752c17 100644 --- a/src/premlike/__init__.py +++ b/src/premlike/__init__.py @@ -5,4 +5,4 @@ from .PREM import PREM __all__ = ["OneDModel", "R_EARTH", "PREM", "tabulate_model"] -__version__ = "0.1.0-alpha1" \ No newline at end of file +__version__ = "0.1.0-alpha2" \ No newline at end of file