Skip to content
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
13 changes: 8 additions & 5 deletions .github/workflows/documentation-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

permissions:
contents: write

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
Expand All @@ -28,7 +31,7 @@ jobs:
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo

- name: Setup Pixi
uses: ./.github/actions/setup-pixi
uses: easyscience/actions/pixi@master

- name: Build documentation
run: pixi run --environment dev docs-build
Expand All @@ -39,8 +42,8 @@ jobs:
# install_requirements: true
# documentation_path: docs/src

- name: Push changes
uses: ad-m/github-push-action@master
continue-on-error: true
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build/html
2 changes: 1 addition & 1 deletion .github/workflows/nightly-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v5

- name: Setup Pixi
uses: ./.github/actions/setup-pixi
uses: easyscience/actions/pixi@master

- name: Update lock file
run: pixi run update-lock
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
steps:
- uses: actions/checkout@v5
- name: Setup Pixi
uses: ./.github/actions/setup-pixi
uses: easyscience/actions/pixi@master
- name: Run linting
run: pixi run lint

Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
- uses: actions/checkout@v5

- name: Setup Pixi
uses: ./.github/actions/setup-pixi
uses: easyscience/actions/pixi@master

- name: Build package
run: pixi run build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- uses: actions/checkout@v5

- name: Setup Pixi
uses: ./.github/actions/setup-pixi
uses: easyscience/actions/pixi@master

- name: Set Python version
run: pixi add python=${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- uses: actions/checkout@v5

- name: Setup Pixi
uses: ./.github/actions/setup-pixi
uses: easyscience/actions/pixi@master

- name: Build package
run: pixi run build
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/verify_issue_labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
with:
secret: ${{ github.TOKEN }}
prefix: "[scope]"
labelSeparator: " "
addLabel: true
defaultLabel: "[scope] ⚠️ label needed"

Expand All @@ -26,6 +27,7 @@ jobs:
with:
secret: ${{ github.TOKEN }}
prefix: "[priority]"
labelSeparator: " "
addLabel: true
defaultLabel: "[priority] ⚠️ label needed"

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
[![PyPI badge](http://img.shields.io/pypi/v/EasyScience.svg)](https://pypi.python.org/pypi/EasyScience)
[![License: BSD 3-Clause](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](LICENSE)
[![codecov](https://codecov.io/github/EasyScience/corelib/graph/badge.svg?token=wc6Q0j0Q9t)](https://codecov.io/github/EasyScience/corelib)

# Easyscience

Expand Down Expand Up @@ -33,7 +34,7 @@ After installation, launch the test suite:

Documentation can be found at:

[https://easyScience.github.io/EasyScience](https://easyScience.github.io/EasyScience)
[https://easyScience.github.io/corelib](https://easyScience.github.io/corelib)

## Contributing
We absolutely welcome contributions. **EasyScience** is maintained by the ESS and on a volunteer basis and thus we need to foster a community that can support user questions and develop new features to make this software a useful tool for all users while encouraging every member of the community to share their ideas.
Expand Down
9 changes: 2 additions & 7 deletions src/easyscience/base_classes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
from .based_base import BasedBase
from .collection_base import CollectionBase
from .easy_list import EasyList
from .model_base import ModelBase
from .new_base import NewBase
from .obj_base import ObjBase

__all__ = [
BasedBase,
CollectionBase,
ObjBase,
ModelBase,
NewBase,
]
__all__ = [BasedBase, CollectionBase, ObjBase, ModelBase, NewBase, EasyList]
23 changes: 14 additions & 9 deletions src/easyscience/base_classes/collection_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from typing import Tuple
from typing import Union

from easyscience.base_classes.new_base import NewBase
from easyscience.global_object.undo_redo import NotarizedDict

from ..variable.descriptor_base import DescriptorBase
Expand All @@ -34,7 +35,7 @@ class CollectionBase(BasedBase, MutableSequence):
def __init__(
self,
name: str,
*args: Union[BasedBase, DescriptorBase],
*args: Union[BasedBase, DescriptorBase, NewBase],
interface: Optional[InterfaceFactoryTemplate] = None,
unique_name: Optional[str] = None,
**kwargs,
Expand Down Expand Up @@ -64,7 +65,7 @@ def __init__(
_kwargs[key] = item
kwargs = _kwargs
for item in list(kwargs.values()) + _args:
if not issubclass(type(item), (DescriptorBase, BasedBase)):
if not issubclass(type(item), (DescriptorBase, BasedBase, NewBase)):
raise AttributeError('A collection can only be formed from easyscience objects.')
args = _args
_kwargs = {}
Expand All @@ -90,19 +91,19 @@ def __init__(
self.interface = interface
self._kwargs._stack_enabled = True

def insert(self, index: int, value: Union[DescriptorBase, BasedBase]) -> None:
def insert(self, index: int, value: Union[DescriptorBase, BasedBase, NewBase]) -> None:
"""
Insert an object into the collection at an index.
:param index: Index for EasyScience object to be inserted.
:type index: int
:param value: Object to be inserted.
:type value: Union[BasedBase, DescriptorBase]
:type value: Union[BasedBase, DescriptorBase, NewBase]
:return: None
:rtype: None
"""
t_ = type(value)
if issubclass(t_, (BasedBase, DescriptorBase)):
if issubclass(t_, (BasedBase, DescriptorBase, NewBase)):
update_key = list(self._kwargs.keys())
values = list(self._kwargs.values())
# Update the internal dict
Expand All @@ -117,7 +118,7 @@ def insert(self, index: int, value: Union[DescriptorBase, BasedBase]) -> None:
else:
raise AttributeError('Only EasyScience objects can be put into an EasyScience group')

def __getitem__(self, idx: Union[int, slice]) -> Union[DescriptorBase, BasedBase]:
def __getitem__(self, idx: Union[int, slice]) -> Union[DescriptorBase, BasedBase, NewBase]:
"""
Get an item in the collection based on its index.
Expand Down Expand Up @@ -151,7 +152,7 @@ def __getitem__(self, idx: Union[int, slice]) -> Union[DescriptorBase, BasedBase
keys = list(self._kwargs.keys())
return self._kwargs[keys[idx]]

def __setitem__(self, key: int, value: Union[BasedBase, DescriptorBase]) -> None:
def __setitem__(self, key: int, value: Union[BasedBase, DescriptorBase, NewBase]) -> None:
"""
Set an item via it's index.
Expand All @@ -163,7 +164,7 @@ def __setitem__(self, key: int, value: Union[BasedBase, DescriptorBase]) -> None
if isinstance(value, Number): # noqa: S3827
item = self.__getitem__(key)
item.value = value
elif issubclass(type(value), (BasedBase, DescriptorBase)):
elif issubclass(type(value), (BasedBase, DescriptorBase, NewBase)):
update_key = list(self._kwargs.keys())
values = list(self._kwargs.values())
old_item = values[key]
Expand Down Expand Up @@ -233,7 +234,11 @@ def data(self) -> Tuple:
def __repr__(self) -> str:
return f'{self.__class__.__name__} `{getattr(self, "name")}` of length {len(self)}'

def sort(self, mapping: Callable[[Union[BasedBase, DescriptorBase]], Any], reverse: bool = False) -> None:
def sort(
self,
mapping: Callable[[Union[BasedBase, DescriptorBase, NewBase]], Any],
reverse: bool = False,
) -> None:
"""
Sort the collection according to the given mapping.
Expand Down
Loading
Loading