Skip to content

Preparation for 1.4.0 release #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Examples/base/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
Subclassing Examples
------------------------

This section gathers examples which correspond to subclassing the :class:`easyscience.Objects.Base.BaseObj` class.
This section gathers examples which correspond to subclassing the :class:`easyscience.base_classes.ObjBase` class.
16 changes: 8 additions & 8 deletions Examples/base/plot_baseclass1.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
Subclassing BaseObj - Simple Pendulum
Subclassing ObjBase - Simple Pendulum
=====================================
This example shows how to subclass :class:`easyscience.Objects.Base.BaseObj` with parameters from
:class:`EasyScience.Objects.Base.Parameter`. For this example a simple pendulum will be modeled.
This example shows how to subclass :class:`easyscience.base_classes.ObjBase` with parameters from
:class:`EasyScience.variable.Parameter`. For this example a simple pendulum will be modeled.

.. math::
y = A \sin (2 \pi f t + \phi )
Expand All @@ -17,8 +17,8 @@
import matplotlib.pyplot as plt
import numpy as np

from easyscience.Objects.ObjectClasses import BaseObj
from easyscience.Objects.ObjectClasses import Parameter
from easyscience.base_classes import ObjBase
from easyscience.variable import Parameter

# %%
# Subclassing
Expand All @@ -29,7 +29,7 @@
# embedded rST text block:


class Pendulum(BaseObj):
class Pendulum(ObjBase):
def __init__(self, A: Parameter, f: Parameter, p: Parameter):
super(Pendulum, self).__init__('SimplePendulum', A=A, f=f, p=p)

Expand All @@ -41,13 +41,13 @@ def from_pars(cls, A: float = 1, f: float = 1, p: float = 0):
return cls(A, f, p)

def __call__(self, t):
return self.A.raw_value * np.sin(2 * np.pi * self.f.raw_value * t + self.p.raw_value)
return self.A.value * np.sin(2 * np.pi * self.f.value * t + self.p.value)

def plot(self, time, axis=None, **kwargs):
if axis is None:
axis = plt
else:
axis.set_title(f'A={self.A.raw_value}, F={self.f.raw_value}, P={self.p.raw_value}')
axis.set_title(f'A={self.A.value}, F={self.f.value}, P={self.p.value}')
p = axis.plot(time, self(time), **kwargs)
return p

Expand Down
6 changes: 0 additions & 6 deletions Examples/fitting/README.rst

This file was deleted.

22 changes: 0 additions & 22 deletions Examples/fitting/plot_constraints.py

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2024, Easyscience contributors (https://github.com/EasyScience)
Copyright (c) 2025, Easyscience contributors (https://github.com/EasyScience)
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
4 changes: 1 addition & 3 deletions docs/src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@

intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'numpy': ('https://numpy.org/doc/stable/', None),
'pint': ('https://pint.readthedocs.io/en/stable/', None),
'xarray': ('https://xarray.pydata.org/en/stable/', None)
'numpy': ('https://numpy.org/doc/stable/', None)
}

# -- General configuration ---------------------------------------------------
Expand Down
75 changes: 0 additions & 75 deletions docs/src/fitting/constraints.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/src/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ Documentation
:maxdepth: 3

fitting/introduction
fitting/constraints

.. toctree::
:maxdepth: 2
Expand Down
23 changes: 5 additions & 18 deletions docs/src/reference/base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Parameters and Objects
Descriptors
===========

.. autoclass:: easyscience.Objects.Variable.Descriptor
.. autoclass:: easyscience.variable.Descriptor
:members:

Parameters
==========

.. autoclass:: easyscience.Objects.Variable.Parameter
.. autoclass:: easyscience.variable.Parameter
:members:
:inherited-members:

Expand All @@ -22,30 +22,17 @@ Super Classes and Collections
Super Classes
=============

.. autoclass:: easyscience.Objects.ObjectClasses.BasedBase
.. autoclass:: easyscience.base_classes.BasedBase
:members:
:inherited-members:

.. autoclass:: easyscience.Objects.ObjectClasses.BaseObj
.. autoclass:: easyscience.base_classes.ObjBase
:members: +_add_component
:inherited-members:

Collections
===========

.. autoclass:: easyscience.Objects.Groups.BaseCollection
.. autoclass:: easyscience.CollectionBase
:members:
:inherited-members:

===============
Data Containers
===============

.. autoclass:: easyscience.Datasets.xarray.EasyScienceDataarrayAccessor
:members:
:inherited-members:

.. autoclass:: easyscience.Datasets.xarray.EasyScienceDatasetAccessor
:members:
:inherited-members:

2 changes: 1 addition & 1 deletion examples_old/example1.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

def fit_fun(x):
# In the real case we would gust call the evaluation fn without reference to the BaseObj
return b.c.raw_value + b.m.raw_value * x
return b.c.value + b.m.value * x


f = Fitter()
Expand Down
2 changes: 1 addition & 1 deletion examples_old/example1_dream.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

def fit_fun(x):
# In the real case we would gust call the evaluation fn without reference to the BaseObj
return b.c.raw_value + b.m.raw_value * x
return b.c.value + b.m.value * x


f = Fitter()
Expand Down
4 changes: 2 additions & 2 deletions examples_old/example2.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def _defaults(self):

@property
def gradient(self):
return self.m.raw_value
return self.m.value

@property
def intercept(self):
return self.c.raw_value
return self.c.value

def fit_func(self, x: np.ndarray) -> np.ndarray:
return self.gradient * x + self.intercept
Expand Down
4 changes: 2 additions & 2 deletions examples_old/example3.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ def gradient(self):
if self.interface:
return self.interface.get_value('m')
else:
return self.m.raw_value
return self.m.value

@property
def intercept(self):
if self.interface:
return self.interface.get_value('c')
else:
return self.c.raw_value
return self.c.value

def fit_func(self, x: np.ndarray) -> np.ndarray:
if self.interface:
Expand Down
6 changes: 3 additions & 3 deletions examples_old/example4.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from easyscience import global_object
from easyscience.fitting import Fitter
from easyscience.Objects.core import ComponentSerializer
from easyscience.Objects.component_serializer import ComponentSerializer
from easyscience.Objects.ObjectClasses import BaseObj
from easyscience.Objects.ObjectClasses import Parameter

Expand Down Expand Up @@ -407,14 +407,14 @@ def gradient(self):
if self.interface:
return self.interface().get_value("m")
else:
return self.m.raw_value
return self.m.value

@property
def intercept(self):
if self.interface:
return self.interface().get_value("c")
else:
return self.c.raw_value
return self.c.value

def __repr__(self):
return f"Line: m={self.m}, c={self.c}"
Expand Down
6 changes: 3 additions & 3 deletions examples_old/example5_broken.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from easyscience.fitting import Fitter
from easyscience.Objects.Base import BaseObj
from easyscience.Objects.Base import Parameter
from easyscience.Objects.core import ComponentSerializer
from easyscience.Objects.component_serializer import ComponentSerializer

# from easyscience.Objects.Base import LoggedProperty
from easyscience.Objects.Inferface import InterfaceFactoryTemplate
Expand Down Expand Up @@ -325,14 +325,14 @@ def gradient(self):
# if self.interface:
# return self.interface().get_value('m')
# else:
return self.m.raw_value
return self.m.value

@property
def intercept(self):
# if self.interface:
# return self.interface().get_value('c')
# else:
return self.c.raw_value
return self.c.value

def __repr__(self):
return f"Line: m={self.m}, c={self.c}"
Expand Down
2 changes: 1 addition & 1 deletion examples_old/example6_broken.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from easyscience.fitting import Fitter
from easyscience.Objects.ObjectClasses import BaseObj
from easyscience.Objects.Variable import Parameter
from easyscience.Objects.core import ComponentSerializer
from easyscience.Objects.component_serializer import ComponentSerializer
from easyscience.Objects.Inferface import InterfaceFactoryTemplate

# This is a much more complex case where we have calculators, interfaces, interface factory and an
Expand Down
2 changes: 1 addition & 1 deletion examples_old/example_dataset2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

def fit_fun(x, *args, **kwargs):
# In the real case we would gust call the evaluation fn without reference to the BaseObj
return b.c.raw_value + b.m.raw_value * x
return b.c.value + b.m.value * x


f = Fitter()
Expand Down
2 changes: 1 addition & 1 deletion examples_old/example_dataset2pt2_broken.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

def fit_fun(x, *args, **kwargs):
# In the real case we would gust call the evaluation fn without reference to the BaseObj
return b.c.raw_value + b.m.raw_value * x
return b.c.value + b.m.value * x


nx = 1E3
Expand Down
2 changes: 1 addition & 1 deletion examples_old/example_dataset3.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

def fit_fun(x, *args, **kwargs):
# In the real case we would gust call the evaluation fn without reference to the BaseObj
return np.sin(2*np.pi*(x[:, 0] + b.s_off.raw_value)) * np.cos(2*np.pi*(x[:, 1] + b.c_off.raw_value))
return np.sin(2*np.pi*(x[:, 0] + b.s_off.value)) * np.cos(2*np.pi*(x[:, 1] + b.c_off.value))


f = Fitter()
Expand Down
4 changes: 2 additions & 2 deletions examples_old/example_dataset3pt2.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

def fit_fun(x, *args, **kwargs):
# In the real case we would gust call the evaluation fn without reference to the BaseObj
return np.sin(2*np.pi*(x[:, 0] + b.s_off.raw_value)) * np.cos(2*np.pi*(x[:, 1] + b.c_off.raw_value))
return np.sin(2*np.pi*(x[:, 0] + b.s_off.value)) * np.cos(2*np.pi*(x[:, 1] + b.c_off.value))


fig, ax = plt.subplots(2, 3, sharey=True, sharex=True)
Expand All @@ -55,7 +55,7 @@ def fit_fun(x, *args, **kwargs):
p1 = d[f'computed_{minimizer}'].plot(ax=ax[0, idx], cbar_kwargs={'cax': cbar_ax1})
p2 = d[f'dz_{minimizer}'].plot(ax=ax[1, idx], cbar_kwargs={'cax': cbar_ax2})
ax[0, idx].set_title(f'{minimizer}')
ax[1, idx].set_title('s_off - {:0.03f}\nc_off - {:0.03f}'.format(b.s_off.raw_value, b.c_off.raw_value))
ax[1, idx].set_title('s_off - {:0.03f}\nc_off - {:0.03f}'.format(b.s_off.value, b.c_off.value))
ax[0, idx].set_aspect('equal', 'box')
ax[1, idx].set_aspect('equal', 'box')
fig.subplots_adjust(right=0.8)
Expand Down
Loading
Loading