Skip to content
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

Merge latest updates #124

Merged
merged 77 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
5ef4052
Update nvecs to use tenmat.
dmdunla Jul 6, 2022
35247d8
Merge pull request #31 from sandialabs/25-tensor-update-nvecs-to-use-…
dmdunla Jul 6, 2022
954e8f1
Full implementation of collapse. Required implementation of tensor.fr…
dmdunla Jul 6, 2022
2d49a25
Update __init__.py
dmdunla Jul 6, 2022
e1b8a56
Create CHANGELOG.md
dmdunla Jul 6, 2022
fcf19e9
Update CHANGELOG.md
dmdunla Jul 6, 2022
6b5af7e
Update CHANGELOG.md
dmdunla Jul 7, 2022
6f4cd9d
Create ci-tests.yml
dmdunla Jul 7, 2022
20cbe8a
Update README.md
dmdunla Jul 7, 2022
bcd6bec
Create requirements.txt
dmdunla Jul 7, 2022
b8c3c2f
33 use standard license (#34)
dmdunla Jul 7, 2022
d1a33db
Delete LICENSE
dmdunla Jul 7, 2022
dfa6cdc
Create LICENSE
dmdunla Jul 7, 2022
d9642a0
Update and rename ci-tests.yml to regression-tests.yml
dmdunla Jul 7, 2022
3f597b5
Update README.md
dmdunla Jul 7, 2022
0bf1f5a
Fix bug in tensor.mttkrp that only showed up when ndims > 3. (#36)
dmdunla Jul 11, 2022
3594769
Update __init__.py
dmdunla Jul 11, 2022
063005e
Bump version
dmdunla Jul 11, 2022
c03d72e
Adding files to support pypi dist creation and uploading
dmdunla Jul 12, 2022
51cf7f6
Fix PyPi installs. Bump version.
dmdunla Jul 12, 2022
0289d97
Fixing np.reshape usage. Adding more tests for tensor.ttv. (#38)
dmdunla Jul 13, 2022
8a2977f
Fixing issues with np.reshape; requires order='F' to align with Matla…
dmdunla Jul 13, 2022
cd32cb7
Bump version.
dmdunla Jul 13, 2022
3b3abcc
Adding tensor.ttm. Adding use case in tenmat to support ttm testing. …
dmdunla Jul 16, 2022
e274d45
Bump version
dmdunla Jul 16, 2022
b2abeda
Format CHANGELOG
dmdunla Jul 16, 2022
402ad3f
Update CHANGELOG.md
dmdunla Jul 16, 2022
e296f3a
pypi puslishing action on release
dmdunla Jul 16, 2022
2ab1934
Allowing rdims or cdims to be empty array. (#43)
dmdunla Jul 18, 2022
16e57a7
Adding tensor.ttt implementation. (#44)
dmdunla Jul 18, 2022
fd31ef9
Bump version
dmdunla Jul 18, 2022
dfd8cd6
Implement ktensor.score and associated tests.
dmdunla Oct 12, 2022
ee45849
Changes to supporting pyttb data classes and associated tests to enab…
dmdunla Oct 12, 2022
598b5bf
Merge pull request #47 from sandialabs/46-ktensor-implement-score
dmdunla Oct 12, 2022
bf26ef6
Bump version.
dmdunla Oct 12, 2022
fbbf554
Merge branch 'main' of github.com:sandialabs/pyttb
dmdunla Oct 12, 2022
d97ca7f
Compatibility with numpy 1.24.x (#49)
brian-kelley Feb 20, 2023
bc83b26
Bump version
dmdunla Feb 20, 2023
eade612
TENSOR: Fix slices ref shen return value isn't scalar or vector. #41 …
ntjohnson1 Feb 21, 2023
eb99634
Ttensor implementation (#51)
ntjohnson1 Feb 21, 2023
4bd5147
Test coverage (#52)
ntjohnson1 Feb 21, 2023
393abe6
Bump version
Feb 21, 2023
e1cb81f
TUCKER_ALS: Add tucker_als to validate ttucker implementation. (#53)
ntjohnson1 Feb 21, 2023
ceb2a91
Bump version of actions (#55)
dmdunla Feb 22, 2023
e5cedce
Tensor docs plus Linting and Typing and Black oh my (#54)
ntjohnson1 Feb 22, 2023
992772b
Auto formatting (#60)
ntjohnson1 Mar 4, 2023
ec36a27
TUCKER_ALS: TTM with negative values is broken in ttensor (#62) (#66)
ntjohnson1 Mar 16, 2023
171aeb0
Hosvd (#67)
ntjohnson1 Mar 16, 2023
961620c
Add test that matches TTB for MATLAB output of HOSVD (#79)
dmdunla Mar 19, 2023
8776944
Bump version (#81)
dmdunla Mar 19, 2023
bdb0ba8
Lint pyttb_utils and lint/type sptensor (#77)
ntjohnson1 Mar 20, 2023
8f64ba4
HOSVD: Negative signs can be permuted for equivalent decomposition (#82)
ntjohnson1 Mar 20, 2023
b1cdc02
Pre commit (#83)
ntjohnson1 Apr 14, 2023
5c6489c
Using dynamic version in pyproject.toml to reduce places where versio…
dmdunla Apr 14, 2023
62a520f
Adding shell=True to subprocess.run() calls (#87)
dmdunla Apr 14, 2023
b3de342
Adding Nick to authors (#89)
dmdunla Apr 14, 2023
5544863
Release prep (#90)
dmdunla Apr 14, 2023
362033b
Fix author for PyPI. Bump to dev version.
dmdunla Apr 14, 2023
18ae68a
Exclude dims (#91)
ntjohnson1 Apr 15, 2023
714e694
Bump version
dmdunla Apr 16, 2023
ab3b410
Spelling
dmdunla Apr 16, 2023
6d26158
Tensor generator helpers (#93)
ntjohnson1 Apr 20, 2023
bc24b67
Link in autodocumentation for recently added code: (#98)
ntjohnson1 Apr 27, 2023
05336d1
Remove warning for nvecs: (#99)
ntjohnson1 Apr 27, 2023
c8bffcb
Rand generators (#100)
ntjohnson1 Apr 27, 2023
e9b314a
Complete pass on ktensor docs. (#101)
dmdunla Apr 27, 2023
cf72bfc
Bump version
dmdunla Apr 27, 2023
48c15b5
Bump version
dmdunla Apr 27, 2023
71c0867
Trying to fix coveralls
dmdunla Apr 29, 2023
71672d6
Trying coveralls github action
dmdunla Apr 29, 2023
6079a1f
Fixing arrange and normalize. (#103)
dmdunla Apr 29, 2023
213ed7d
Rename contributor guide for github magic (#106)
ntjohnson1 May 4, 2023
4284885
Fixed the mean and stdev typo for cp_als (#117)
DeepBlockDeepak May 31, 2023
92a3d6e
Changed cp_als() param 'tensor' to 'input_tensor' to avoid ambiguity …
DeepBlockDeepak May 31, 2023
ea3b9a6
Updated all `tensor`-named paramteres to `input_tensor`, including in…
DeepBlockDeepak May 31, 2023
c443073
Tensor growth (#109)
ntjohnson1 Jun 1, 2023
060423e
Tensor indexing (#116)
ntjohnson1 Jun 2, 2023
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
39 changes: 39 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
47 changes: 47 additions & 0 deletions .github/workflows/regression-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Regression tests

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install coverage coveralls sphinx_rtd_theme
pip install ".[dev]"
- name: Check auto-formatters
run: |
isort --check .
black --check .
# - name: Lint with flake8
# run: |
# # stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Run tests
run: |
coverage run --source pyttb -m pytest tests/
coverage report
- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repos:
- repo: https://github.com/pycqa/isort
rev: 5.11.5
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
language_version: python
109 changes: 109 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# v1.6.1 (2023-04-27)
- New:
- Tensor generator helpers:
- `tenones`, `tenzeros`, `tendiag`, `sptendiag` (PR https://github.com/sandialabs/pyttb/pull/93)
- `tenrand`, `sptenrand` (PR https://github.com/sandialabs/pyttb/pull/100)
- Moved to using `logging` instead of `warnings` (PR https://github.com/sandialabs/pyttb/pull/99)
- Documentation:
- Completed: `ktensor` (PR https://github.com/sandialabs/pyttb/pull/101)
- Fixed linking for new classes (PR https://github.com/sandialabs/pyttb/pull/98)
# v1.6.0 (2023-04-16)
- API Change (PR https://github.com/sandialabs/pyttb/pull/91)
- *Not backwards compatible*
- `pyttb_utils.tt_dimscheck`
- Addresses ambiguity of -0 by using `exclude_dims` (`numpy.ndarray`) parameter
- `ktensor.ttv`, `sptensor.ttv`, `tensor.ttv`, `ttensor.ttv`
- Use `exlude_dims` parameter instead of `-dims`
- Explicit nameing of dimensions to exclude
- `tensor.ttsv`
- Use `skip_dim` (`int`) parameter instead of `-dims`
- Exclude all dimensions up to and including `skip_dim`
- Fixes/Completed:
- Code cleaning: minor changes associated with replacing `-dims` with `exclude_dims`/`skip_dim`
- Authorship: PyPI only allows one author, changing to current POC

# v1.5.1 (2023-04-14)
- New:
- Dev Support:
- Linting: support for `pyttb_utils` and `sptensor` (PR https://github.com/sandialabs/pyttb/pull/77)
- Pre-commit: support @ntjohnson1 in (PR https://github.com/sandialabs/pyttb/pull/83)
- Fixed/Completed:
- `hosvd`: Negative signs can be permuted for equivalent decomposition (PR https://github.com/sandialabs/pyttb/pull/82)
- Versioning: using dynamic version in pyproject.toml (PR https://github.com/sandialabs/pyttb/pull/86)
- Package Testing: fixed problem with subprocesses (PR https://github.com/sandialabs/pyttb/pull/87)

# v1.5.0 (2023-03-19)
- New:
- Added `hosvd` Tuecker decomposition (Issue #56, PR #67)
- Added `tucker_als` Tuecker decomposition (PR #66)
- Autoformatting using `black` and `isort` (Issue #59, PR #60)
- Updated/Ongoing:
- Included more testing for improved coverage (Issue #78, PR #79)

# v1.4.0 (2023-02-21)
- New:
- Added `ttensor` class and associated tests (Issue #10, PR #51)
- Fixed/Completed:
- Tensor slicing now passes through to `numpy` array slicing (Issue #41, PR #50)
- Updated/Ongoing:
- Included more testing for improved coverage (Issue #14, PR #52)

# v1.3.9 (2023-02-20)
- Remove deprecated `numpy` code associated with aliases to built-in types and ragged arrays (Issue #48, PR #49)

# v1.3.8 (2022-10-12)
- Fixed `pyttb_utils.tt_ind2sub` (Issue #45, PR #47)
- Implemented `ktensor.score` (Issue #46, PR #47)

# v1.3.7 (2022-07-17)
- Fixed `tenmat` to accept empty arrays for `rdims` or `cdims` (Issue #42, PR #43)
- Implemented `tensor.ttt` (Issue #28, PR #44)
- Adding GitHub action to publish releases to PyPi

# v1.3.6 (2022-07-15)
- Implemented `tensor.ttm` (Issue #27, PR #40)

# v1.3.5 (2022-07-12)
- Fixing `np.reshape` in `tensor.ttv` (Issue #37, PR #38)
- Fixing `np.reshape` in remainder of `tensor` (Issue #30, PR #39)

# v1.3.4 (2022-07-12)
- Fixing issues with PyPi uploads

# v1.3.3 (2022-07-11)
- Fixed indexing bug in `tensor.mttkrp` (Issue #35, PR #36)
- Updated LICENSE to compliant format (Issue #33 , PR #34)
- Now using [coveralls.io](https://coveralls.io/github/sandialabs/pyttb) for coverage reporting
- Now using [readthedocs.io](https://pyttb.readthedocs.io/en/latest/) for documentation

# v1.3.2 (2022-07-06)
- Update `tensor.nvecs` to use `tenmat` (Issue #25, PR #31)
- Full implementation of `tensor.collapse` (Issue #2, PR #32)
- Added `CHANGELOG.md`

# v1.3.1 (2022-07-01)
- Using `pyttb.__version__` for specifying package version in code and docs
- Implemented `tenmat.__setitem__` and tests (#23)
- Fix warnings in `cp_apr` associated with divide by zero (#13)
- Several documentation fixes.

# v1.3.0 (2022-07-01)
- Changed package name to `pyttb` (#24)

# v1.2.0 (2022-07-01)
- Added `tenmat` class and associated tests (#8)
- Added `tensor.__rmul__` for preadding scalars (#18)
- Fixed error in `sptensor.__lt__` that led to creation of large boolean tensors when comparing with 0 (#15)
- Matched output of `cp_als` to Matlab (#17)

# v1.1.1 (2022-06-29)
- Fixed `tensor/mttkrp` use of `np.reshape` (#16)
- Now updating version numbers in `setup.py`

# v1.1.0 (2022-06-27)
- Fixed `import_data` method
- New `export_data` method
- More testing

# v1.0.0 (2022-06-27)
- Initial release of Python Tensor Toolbox
54 changes: 54 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Python Tensor Toolbox Contributor Guide

## Issues
If you are looking to get started or want to propose a change please start by checking
current or filing a new [issue](https://github.com/sandialabs/pyttb/issues).

## Working on PYTTB locally
1. clone your fork and enter the directory
```
$ git clone [email protected]:<your username>/pyttb.git
$ cd pyttb
```
1. setup your desired python environment as appropriate

1. install dependencies
```
$ pip install -e ".[dev]"
$ make install_dev # shorthand for above
```

1. Checkout a branch and make your changes
```
git checkout -b my-new-feature-branch
```
1. Formatters and linting
1. Run autoformatters from root of project (they will change your code)
```commandline
$ isort .
$ black .
```
1. [We](./.pre-commit-config.yaml) optionally support [pre-commit hooks](https://pre-commit.com/) for this
1. Pylint and mypy coverage is work in progress (these only raise errors)
```commandline
mypy pyttb/
pylint pyttb/file_name.py //Today only tensor is compliant
```

1. Run tests (at desired fidelity)
1. Just doctests (enabled by default)
```commandline
pytest
```
1. Functional tests
```commandline
pytest .
```
1. All tests (linting and formatting checks)
```commandline
pytest . --packaging
```
1. With coverage
```commandline
pytest . --cov=pyttb --cov-report=term-missing
```
18 changes: 13 additions & 5 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ U.S. Government retains certain rights in this software.

## Contributors

**Primary POC:** Danny Dunlavy, [email protected]
**Primary POC:** [Danny Dunlavy](@dmdunla)

**Contributors:**
* Danny Dunlavy - original author, `sptensor`, `ktensor`, `tensor`, `tenmat`, `cp_als`, `cp_apr`
* Nick Johnson - original author, `sptensor`, `ktensor`, `tensor`, `cp_als`, `cp_apr`
* Derek Tucker - `tensor`
**Main Developers:**

- [Danny Dunlavy](@dmdunla) - original author, `sptensor`, `ktensor`, `tensor`, `tenmat`, `cp_als`, `cp_apr`,
[PRs](https://github.com/sandialabs/pyttb/commits?author=dmdunla)
- [Nick Johnson](@ntjohnson1) - original author, `sptensor`, `ktensor`, `tensor`, `ttensor`, `cp_als`, `cp_apr`,
[PRs](https://github.com/sandialabs/pyttb/commits?author=ntjohnson1)

**Other Contributors:**
- [Brian Kelley](@brian_kelley) - `numpy` compatability,
[PRs](https://github.com/sandialabs/pyttb/commits?author=brian-kelley)
- [Derek Tucker](@jdtuck)[#1] - `tensor`,
[PRs](https://github.com/sandialabs/pyttb/commits?author=jdtuck)
5 changes: 2 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
BSD 2-Clause License

Copyright 2022 National Technology & Engineering Solutions of Sandia,
LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the
U.S. Government retains certain rights in this software.
Copyright (c) 2022, National Technology & Engineering Solutions of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains certain rights in this software.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Expand Down
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,24 @@ BUILDDIR = ./docs/build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@echo "install: Install release build"
@echo "install_dev: Install dev build"
@echo "install_docs: Install docs build"
@echo "docs_help: Show additional docs commands"

.PHONY: help install install_dev install_docs Makefile

install:
python -m pip install -e .

.PHONY: help Makefile
install_dev:
python -m pip install -e ".[dev]"

install_docs:
python -m pip install -e ".[doc]"

docs_help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
Expand Down
40 changes: 18 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,26 @@ U.S. Government retains certain rights in this software.

# pyttb: Python Tensor Toolbox

## Contributors
* Danny Dunlavy, Nick Johnson, Derek Tucker
Welcome to `pyttb`, a set of Python classes and methods functions for
manipulating dense, sparse, and structured tensors, along with algorithms
for computing low-rank tensor models.

## Quick start
**Tensor Classes:**
* `tensor`: dense tensors
* `sptensor`: sparse tensors
* `ktensor`: Kruskal tensors
* `tenmat`: matricized tensors
* `ttensor`: Tucker tensors

### Install
* User: ```python setup.py install```
* Developer: ```python setup.py develop```
**Tensor Algorithms:**
* `cp_als`, `cp_apr`: Canonical Polyadic (CP) decompositions
* `tucker_als`: Tucker decompostions

### Testing
```
python -m pytest
```
# Getting Started
Check out the [Documentation](https://pyttb.readthedocs.io) to get started.

### Coverage Testing
```
pytest --cov=pyttb tests/ --cov-report=html
# output can be accessed via htmlcov/index.html
```

### Documentation
```
# requires `sphinx`
sphinx-build ./docs/source ./docs/build/html
# output can be accessed via docs/build/html/index.html
```
# Contributing
Check out our [contributing guide](CONTRIBUTING.md).

---
[![Regression tests](https://github.com/sandialabs/pyttb/actions/workflows/regression-tests.yml/badge.svg)](https://github.com/sandialabs/pyttb/actions/workflows/regression-tests.yml) [![Coverage Status](https://coveralls.io/repos/github/sandialabs/pyttb/badge.svg?branch=main)](https://coveralls.io/github/sandialabs/pyttb?branch=main)
Loading