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

Fixing np.reshape usage. Adding more tests for tensor.ttv. #38

Merged
merged 1 commit into from
Jul 13, 2022

Conversation

dmdunla
Copy link
Collaborator

@dmdunla dmdunla commented Jul 13, 2022

Closes #37.

@dmdunla dmdunla linked an issue Jul 13, 2022 that may be closed by this pull request
@dmdunla dmdunla merged commit 0289d97 into main Jul 13, 2022
@dmdunla dmdunla deleted the 37-tensorttv-use-of-npreshape-is-incorrect branch July 13, 2022 03:10
dmdunla added a commit that referenced this pull request Jun 2, 2023
* Update nvecs to use tenmat.

* Full implementation of collapse. Required implementation of tensor.from_tensor_type for tenmat objects. Updated tensor tests. (#32)

* Update __init__.py

Bump version.

* Create CHANGELOG.md

Changelog update

* Update CHANGELOG.md

Consistent formatting

* Update CHANGELOG.md

Correction

* Create ci-tests.yml

* Update README.md

Adding coverage statistics from coveralls.io

* Create requirements.txt

* 33 use standard license (#34)

* Use standard, correctly formatted LICENSE

* Delete LICENSE

* Create LICENSE

* Update and rename ci-tests.yml to regression-tests.yml

* Update README.md

* Fix bug in tensor.mttkrp that only showed up when ndims > 3. (#36)

* Update __init__.py

Bump version

* Bump version

* Adding files to support pypi dist creation and uploading

* Fix PyPi installs. Bump version.

* Fixing np.reshape usage. Adding more tests for tensor.ttv. (#38)

* Fixing issues with np.reshape; requires order='F' to align with Matlab functionality. (#39)

Closes #30 .

* Bump version.

* Adding tensor.ttm. Adding use case in tenmat to support ttm testing. (#40)

Closes #27

* Bump version

* Format CHANGELOG

* Update CHANGELOG.md

* pypi puslishing action on release

* Allowing rdims or cdims to be empty array. (#43)

Closes #42

* Adding  tensor.ttt implementation. (#44)

Closes 28

* Bump version

* Implement ktensor.score and associated tests.

* Changes to supporting pyttb data classes and associated tests to enable ktensor.score.

* Bump version.

* Compatibility with numpy 1.24.x (#49)

Close #48 

* Replace "numpy.float" with equivalent "float"

numpy.float was deprecated in 1.20 and removed in 1.24

* sptensor.ttv: support 'vector' being a plain list

(rather than just numpy.ndarray). Backwards compatible - an ndarray
argument still works. This is because in newer numpy, it's not allowed to do
np.array(list) where the elements of list are ndarrays of different shapes.

* Make ktensor.innerprod call ttv with 'vector' as plain list

(instead of numpy.ndarray, because newer versions don't allow ragged arrays)

* tensor.ttv: avoid ragged numpy arrays

* Fix two unit test failures due to numpy related changes

* More numpy updates

- numpy.int is removed - use int instead
- don't try to construct ragged/inhomogeneous numpy arrays in tests.
  Use plain lists of vectors instead

* Fix typo in assert message

* Let ttb.tt_dimscheck catch empty input error

In the three ttv methods, ttb.tt_dimscheck checks that 'vector' argument
is not an empty list/ndarray. Revert previous changes that checked for this
before calling tt_dimscheck.

* Bump version

* TENSOR: Fix slices ref shen return value isn't scalar or vector. #41 (#50)

Closes #41

* Ttensor implementation (#51)

* TENSOR: Fix slices ref shen return value isn't scalar or vector. #41

* TTENSOR: Add tensor creation (partial support of core tensor types) and display

* SPTENSOR: Add numpy scalar type for multiplication filter.

* TTENSOR: Double, full, isequal, mtimes, ndims, size, uminus, uplus, and partial innerprod.

* TTENSOR: TTV (finishes innerprod), mttkrp, and norm

* TTENSOR: TTM, permute and minor cleanup.

* TTENSOR: Reconstruct

* TTENSOR: Nvecs

* SPTENSOR:
* Fix argument mismatch for ttm (modes s.b. dims)
* Fix ttm for rectangular matrices
* Make error message consitent with tensor
TENSOR:
* Fix error message

* TTENSOR: Improve test coverage and corresponding bug fixes discovered.

* Test coverage (#52)

* SPTENSOR:
* Fix argument mismatch for ttm (modes s.b. dims)
* Fix ttm for rectangular matrices
* Make error message consitent with tensor
TENSOR:
* Fix error message

* SPTENSOR: Improve test coverage, replace prints, and some doc string fixes.

* PYTTUB_UTILS: Improve test coverage

* TENMAT: Remove impossible condition. Shape is a property, the property handles the (0,) shape condition. So ndims should never see it.

* TENSOR: Improve test coverage. One line left, but logic of setitem is unclear without MATLAB validation of behavior.

* CP_APR: Add tests fpr sptensor, and corresponding bug fixes to improve test coverage.

---------

Co-authored-by: Danny Dunlavy <[email protected]>

* Bump version

* TUCKER_ALS: Add tucker_als to validate ttucker implementation. (#53)

* Bump version of actions (#55)

actions/setup-python@v4 to avoid deprecation warnings

* Tensor docs plus Linting and Typing and Black oh my (#54)

* TENSOR: Apply black and enforce it

* TENSOR: Add isort and pylint. Fix to pass then enforce

* TENSOR: Variety of linked fixes:
* Add mypy type checking
* Update infrastructure for validating package
* Fix doc tests and add more examples

* DOCTEST: Add doctest automatically to regression
* Fix existing failures

* DOCTEST: Fix non-uniform array

* DOCTEST: Fix precision errors in example

* AUTOMATION: Add test directory otherwise only doctests run

* TENSOR: Fix bad rebase from numpy fix

* Auto formatting (#60)

* COVERAGE: Fix some coverage regressions from pylint PR

* ISORT: Run isort on source and tests

* BLACK: Run black on source and tests

* BLACK: Run black on source and tests

* FORMATTING: Add tests and verification for autoformatting

* FORMATTING: Add black/isort to root to simplify

* Add preliminary contributor guide instructions

Closes #59

* TUCKER_ALS: TTM with negative values is broken in ttensor (#62) (#66)

* Replace usage in tucker_als
* Update test for tucker_als to ensure result matches expectation
* Add early error handling in ttensor ttm for negative dims

* Hosvd (#67)

* HOSVD: Preliminary outline of core functionality

* HOSVD: Fix numeric bug
* Was slicing incorrectly
* Update test to check convergence

* HOSVD: Finish output and test coverage

* TENSOR: Prune numbers real
* Real and mypy don't play nice python/mypy#3186
* This allows partial typing support of HOSVD

* Add test that matches TTB for MATLAB output of HOSVD (#79)

This closes #78

* Bump version (#81)

Closes #80

* Lint pyttb_utils and lint/type sptensor (#77)

* PYTTB_UTILS: Fix and enforce pylint

* PYTTB_UTILS: Pull out utility only used internally in sptensor

* SPTENSOR: Fix and enforce pylint

* SPTENSOR: Initial pass a typing support

* SPTENSOR: Complete initial typing coverage

* SPTENSOR: Fix test coverage from typing changes.

* PYLINT: Update test to lint files in parallel to improve dev experience.

* HOSVD: Negative signs can be permuted for equivalent decomposition (#82)

* Pre commit (#83)

* Setup and pyproject are redundant. Remove and resolve install issue

* Try adding pre-commit hooks

* Update Makefile for simplicity and add notes to contributor guide.

* Make pre-commit optional opt-in

* Make regression tests use simplified dependencies so we track fewer places.

* Using dynamic version in pyproject.toml to reduce places where version is set. (#86)

* Adding shell=True to subprocess.run() calls (#87)

* Adding Nick to authors (#89)

* Release prep (#90)

* Fix author for PyPI. Bump to dev version.

* Exclude dims (#91)

* Explicit Exclude_dims:
* Updated tt_dimscheck
* Update all uses of tt_dimscheck and propagate interface

* Add test coverage for exclude dims changes

* Tucker_als: Fix workaround that motivated exclude_dims

* Bump version

* Spelling

* Tensor generator helpers (#93)

* TENONES: Add initial tenones support

* TENZEROS: Add initial tenzeros support

* TENDIAG: Add initial tendiag support

* SPTENDIAG: Add initial sptendiag support

* Link in autodocumentation for recently added code: (#98)

* TTENSOR, HOSVD, TUCKER_ALS, Tensor generators

* Remove warning for nvecs: (#99)

* Make debug level log for now
* Remove test enforcement

* Rand generators (#100)

* Non-functional change:
* Fix numpy deprecation warning, logic should be equivalent

* Tenrand initial implementation

* Sptenrand initial implementation

* Complete pass on ktensor docs. (#101)

* Bump version

* Bump version

* Trying to fix coveralls

* Trying coveralls github action

* Fixing arrange and normalize. (#103)

* Fixing arrange and normalize.

* Merge main (#104)

* Trying to fix coveralls

* Trying coveralls github action

* Rename contributor guide for github magic (#106)

* Rename contributor guide for github magic

* Update reference to contributor guide from README

* Fixed the mean and stdev typo for cp_als (#117)

* Changed cp_als() param 'tensor' to 'input_tensor' to avoid ambiguity (#118)

* Changed cp_als() param 'tensor' to 'input_tensor' to avoid ambiguity

* Formatted changes with isort and black.

* Updated all `tensor`-named paramteres to `input_tensor`, including in docs (#120)

* Tensor growth (#109)

* Tensor.__setitem__: Break into methods
* Non-functional change to make logic flow clearer

* Tensor.__setitem__: Fix some types to resolve edge cases

* Sptensor.__setitem__: Break into methods
* Non-functional change to make flow clearer

* Sptensor.__setitem__: Catch additional edge cases in sptensor indexing

* Tensor.__setitem__: Catch subtensor additional dim growth

* Tensor indexing (#116)

* Tensor.__setitem__/__getitem__: Fix linear index
* Before required numpy array now works on value/slice/Iterable

* Tensor.__getitem__: Fix subscripts usage
* Consistent with setitem now
* Update usages (primarily in sptensor)

* Sptensor.__setitem__/__getitem__: Fix subscripts usage
* Consistent with tensor and MATLAB now
* Update test usage

* sptensor: Add coverage for improved indexing capability

* tensor: Add coverage for improved indexing capability

---------

Co-authored-by: brian-kelley <[email protected]>
Co-authored-by: ntjohnson1 <[email protected]>
Co-authored-by: Dunlavy <[email protected]>
Co-authored-by: DeepBlockDeepak <[email protected]>
dmdunla added a commit that referenced this pull request Jun 3, 2023
* Merge latest updates (#124)

* Update nvecs to use tenmat.

* Full implementation of collapse. Required implementation of tensor.from_tensor_type for tenmat objects. Updated tensor tests. (#32)

* Update __init__.py

Bump version.

* Create CHANGELOG.md

Changelog update

* Update CHANGELOG.md

Consistent formatting

* Update CHANGELOG.md

Correction

* Create ci-tests.yml

* Update README.md

Adding coverage statistics from coveralls.io

* Create requirements.txt

* 33 use standard license (#34)

* Use standard, correctly formatted LICENSE

* Delete LICENSE

* Create LICENSE

* Update and rename ci-tests.yml to regression-tests.yml

* Update README.md

* Fix bug in tensor.mttkrp that only showed up when ndims > 3. (#36)

* Update __init__.py

Bump version

* Bump version

* Adding files to support pypi dist creation and uploading

* Fix PyPi installs. Bump version.

* Fixing np.reshape usage. Adding more tests for tensor.ttv. (#38)

* Fixing issues with np.reshape; requires order='F' to align with Matlab functionality. (#39)

Closes #30 .

* Bump version.

* Adding tensor.ttm. Adding use case in tenmat to support ttm testing. (#40)

Closes #27

* Bump version

* Format CHANGELOG

* Update CHANGELOG.md

* pypi puslishing action on release

* Allowing rdims or cdims to be empty array. (#43)

Closes #42

* Adding  tensor.ttt implementation. (#44)

Closes 28

* Bump version

* Implement ktensor.score and associated tests.

* Changes to supporting pyttb data classes and associated tests to enable ktensor.score.

* Bump version.

* Compatibility with numpy 1.24.x (#49)

Close #48 

* Replace "numpy.float" with equivalent "float"

numpy.float was deprecated in 1.20 and removed in 1.24

* sptensor.ttv: support 'vector' being a plain list

(rather than just numpy.ndarray). Backwards compatible - an ndarray
argument still works. This is because in newer numpy, it's not allowed to do
np.array(list) where the elements of list are ndarrays of different shapes.

* Make ktensor.innerprod call ttv with 'vector' as plain list

(instead of numpy.ndarray, because newer versions don't allow ragged arrays)

* tensor.ttv: avoid ragged numpy arrays

* Fix two unit test failures due to numpy related changes

* More numpy updates

- numpy.int is removed - use int instead
- don't try to construct ragged/inhomogeneous numpy arrays in tests.
  Use plain lists of vectors instead

* Fix typo in assert message

* Let ttb.tt_dimscheck catch empty input error

In the three ttv methods, ttb.tt_dimscheck checks that 'vector' argument
is not an empty list/ndarray. Revert previous changes that checked for this
before calling tt_dimscheck.

* Bump version

* TENSOR: Fix slices ref shen return value isn't scalar or vector. #41 (#50)

Closes #41

* Ttensor implementation (#51)

* TENSOR: Fix slices ref shen return value isn't scalar or vector. #41

* TTENSOR: Add tensor creation (partial support of core tensor types) and display

* SPTENSOR: Add numpy scalar type for multiplication filter.

* TTENSOR: Double, full, isequal, mtimes, ndims, size, uminus, uplus, and partial innerprod.

* TTENSOR: TTV (finishes innerprod), mttkrp, and norm

* TTENSOR: TTM, permute and minor cleanup.

* TTENSOR: Reconstruct

* TTENSOR: Nvecs

* SPTENSOR:
* Fix argument mismatch for ttm (modes s.b. dims)
* Fix ttm for rectangular matrices
* Make error message consitent with tensor
TENSOR:
* Fix error message

* TTENSOR: Improve test coverage and corresponding bug fixes discovered.

* Test coverage (#52)

* SPTENSOR:
* Fix argument mismatch for ttm (modes s.b. dims)
* Fix ttm for rectangular matrices
* Make error message consitent with tensor
TENSOR:
* Fix error message

* SPTENSOR: Improve test coverage, replace prints, and some doc string fixes.

* PYTTUB_UTILS: Improve test coverage

* TENMAT: Remove impossible condition. Shape is a property, the property handles the (0,) shape condition. So ndims should never see it.

* TENSOR: Improve test coverage. One line left, but logic of setitem is unclear without MATLAB validation of behavior.

* CP_APR: Add tests fpr sptensor, and corresponding bug fixes to improve test coverage.

---------

Co-authored-by: Danny Dunlavy <[email protected]>

* Bump version

* TUCKER_ALS: Add tucker_als to validate ttucker implementation. (#53)

* Bump version of actions (#55)

actions/setup-python@v4 to avoid deprecation warnings

* Tensor docs plus Linting and Typing and Black oh my (#54)

* TENSOR: Apply black and enforce it

* TENSOR: Add isort and pylint. Fix to pass then enforce

* TENSOR: Variety of linked fixes:
* Add mypy type checking
* Update infrastructure for validating package
* Fix doc tests and add more examples

* DOCTEST: Add doctest automatically to regression
* Fix existing failures

* DOCTEST: Fix non-uniform array

* DOCTEST: Fix precision errors in example

* AUTOMATION: Add test directory otherwise only doctests run

* TENSOR: Fix bad rebase from numpy fix

* Auto formatting (#60)

* COVERAGE: Fix some coverage regressions from pylint PR

* ISORT: Run isort on source and tests

* BLACK: Run black on source and tests

* BLACK: Run black on source and tests

* FORMATTING: Add tests and verification for autoformatting

* FORMATTING: Add black/isort to root to simplify

* Add preliminary contributor guide instructions

Closes #59

* TUCKER_ALS: TTM with negative values is broken in ttensor (#62) (#66)

* Replace usage in tucker_als
* Update test for tucker_als to ensure result matches expectation
* Add early error handling in ttensor ttm for negative dims

* Hosvd (#67)

* HOSVD: Preliminary outline of core functionality

* HOSVD: Fix numeric bug
* Was slicing incorrectly
* Update test to check convergence

* HOSVD: Finish output and test coverage

* TENSOR: Prune numbers real
* Real and mypy don't play nice python/mypy#3186
* This allows partial typing support of HOSVD

* Add test that matches TTB for MATLAB output of HOSVD (#79)

This closes #78

* Bump version (#81)

Closes #80

* Lint pyttb_utils and lint/type sptensor (#77)

* PYTTB_UTILS: Fix and enforce pylint

* PYTTB_UTILS: Pull out utility only used internally in sptensor

* SPTENSOR: Fix and enforce pylint

* SPTENSOR: Initial pass a typing support

* SPTENSOR: Complete initial typing coverage

* SPTENSOR: Fix test coverage from typing changes.

* PYLINT: Update test to lint files in parallel to improve dev experience.

* HOSVD: Negative signs can be permuted for equivalent decomposition (#82)

* Pre commit (#83)

* Setup and pyproject are redundant. Remove and resolve install issue

* Try adding pre-commit hooks

* Update Makefile for simplicity and add notes to contributor guide.

* Make pre-commit optional opt-in

* Make regression tests use simplified dependencies so we track fewer places.

* Using dynamic version in pyproject.toml to reduce places where version is set. (#86)

* Adding shell=True to subprocess.run() calls (#87)

* Adding Nick to authors (#89)

* Release prep (#90)

* Fix author for PyPI. Bump to dev version.

* Exclude dims (#91)

* Explicit Exclude_dims:
* Updated tt_dimscheck
* Update all uses of tt_dimscheck and propagate interface

* Add test coverage for exclude dims changes

* Tucker_als: Fix workaround that motivated exclude_dims

* Bump version

* Spelling

* Tensor generator helpers (#93)

* TENONES: Add initial tenones support

* TENZEROS: Add initial tenzeros support

* TENDIAG: Add initial tendiag support

* SPTENDIAG: Add initial sptendiag support

* Link in autodocumentation for recently added code: (#98)

* TTENSOR, HOSVD, TUCKER_ALS, Tensor generators

* Remove warning for nvecs: (#99)

* Make debug level log for now
* Remove test enforcement

* Rand generators (#100)

* Non-functional change:
* Fix numpy deprecation warning, logic should be equivalent

* Tenrand initial implementation

* Sptenrand initial implementation

* Complete pass on ktensor docs. (#101)

* Bump version

* Bump version

* Trying to fix coveralls

* Trying coveralls github action

* Fixing arrange and normalize. (#103)

* Fixing arrange and normalize.

* Merge main (#104)

* Trying to fix coveralls

* Trying coveralls github action

* Rename contributor guide for github magic (#106)

* Rename contributor guide for github magic

* Update reference to contributor guide from README

* Fixed the mean and stdev typo for cp_als (#117)

* Changed cp_als() param 'tensor' to 'input_tensor' to avoid ambiguity (#118)

* Changed cp_als() param 'tensor' to 'input_tensor' to avoid ambiguity

* Formatted changes with isort and black.

* Updated all `tensor`-named paramteres to `input_tensor`, including in docs (#120)

* Tensor growth (#109)

* Tensor.__setitem__: Break into methods
* Non-functional change to make logic flow clearer

* Tensor.__setitem__: Fix some types to resolve edge cases

* Sptensor.__setitem__: Break into methods
* Non-functional change to make flow clearer

* Sptensor.__setitem__: Catch additional edge cases in sptensor indexing

* Tensor.__setitem__: Catch subtensor additional dim growth

* Tensor indexing (#116)

* Tensor.__setitem__/__getitem__: Fix linear index
* Before required numpy array now works on value/slice/Iterable

* Tensor.__getitem__: Fix subscripts usage
* Consistent with setitem now
* Update usages (primarily in sptensor)

* Sptensor.__setitem__/__getitem__: Fix subscripts usage
* Consistent with tensor and MATLAB now
* Update test usage

* sptensor: Add coverage for improved indexing capability

* tensor: Add coverage for improved indexing capability

---------

Co-authored-by: brian-kelley <[email protected]>
Co-authored-by: ntjohnson1 <[email protected]>
Co-authored-by: Dunlavy <[email protected]>
Co-authored-by: DeepBlockDeepak <[email protected]>

* Adding tests and data for import_data, export_data, sptensor, ktensor. Small changes in code that was unreachable.

* Updating formatting with black

* More updates for coverage.

* Black formatting updates

* Update regression-tests.yml

Adding verbose to black and isort calls

* Black updated locally to align with CI testing

* Update regression-tests.yml

---------

Co-authored-by: brian-kelley <[email protected]>
Co-authored-by: ntjohnson1 <[email protected]>
Co-authored-by: Dunlavy <[email protected]>
Co-authored-by: DeepBlockDeepak <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tensor.ttv: use of np.reshape is incorrect
1 participant