-
Notifications
You must be signed in to change notification settings - Fork 12
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
11 import datasptensor check dimensions on import #207
11 import datasptensor check dimensions on import #207
Conversation
… if an index is found that is less than zero or gte to the size of the dimension it indexes, a ValueError is raised.
Can we use one of our existing validation utilities? Line 688 in 9c150cb
Can we add a test to make sure we maintain this behavior? Also does this catch the situation where the shape provided is the wrong number of dimensions?
Additional note, iterating in python is slow. The reason we use the invalidated from_data is for speed. from_aggregation will already do validation and adjustment to account for accident duplicates etc. Instead of looping over every sub (row) then index (col). You should be able to compare all the subs against the shape via a broadcast as a single numpy call then check if anything fails. Here is where we do something similar in from_aggregation to find the minimum acceptable shape to fit provided entries Line 318 in 9c150cb
|
This only checks that the shape and type of the Line 688 in 9c150cb
Nick's idea of using vectorized methods would be an improvement. Something like: all(a <= b for a, b in zip(tuple(np.max(subs, axis=0) + 1), shape) So, a combination of |
This seems to be broken. Any updates? |
Nothing so far but I am planning on taking a look soon. |
…bscheck() returns True, meaning empty subscript arrays are considered valid in the sptensor constructor.
@DeepBlockDeepak Can you update this now that the default |
* tensor Update __init__ and remove from_data: * Update all usages * tensor add explicit copy and deepcopy dunder * sptensor update __init__ and remove from_data * sptensor add copy and deepcopy dunder * ttensor: Rename u to factor_matrices to match ktensor. * ruff: Add minimal coverage to tests dir: * We can now run ruff check . from root * Fix imports unused, unsorted in tests * Fix fstring errors, unused variables, etc * All test changes via ruff check . --fix * ttensor: update __init__ and remove from_data * ttensor: add copy and dunder deepcopy * ttensor: Remove from_tensor_type * Only worked as copy constructor before so explicit copy replaces * tensor: Remove from_tensor_type: * Push to_tensor to all callers * ruff: Add bugbear to catch bugs and better align with pylint * pylint: Disable false positive if we don't remove pylint first * sptensor: Remove from_tensor and push conversion to callers * ttensor: Add to_tensor * tutorials: Update to use new interfaces * Updated doc and test to capture or ruff support of tests directory: * Basically just keep imports reasonable and avoid logic errors (unused variables etc) * Missed a pylint disable statement in the rebase. A search over the project no longer matches pylint * Documentation consistency: * Remove undocumented methods/members * No longer need to explicitly exclude members by name * Move all tensor types to use slots * Don't skip __init__ since we were dropping that entire doc string * Documentation style: * Merges __init__ with class definition instead of a separate __init__ entry * Add forgotten arguments to docstring
This now looks like there is no change from |
It doesn't look like this PR ever added a test for the expected behavior. I don't think I fixed anything in #213 so I assume this is still an issue (could check with the repro in the PR description), and the non-change is just a bad conflict resolution. |
…-check-dimensions-on-import
* Added as an assert so `python -O` can run to skip it if desired
…g the error in CI.
@dmdunla @DeepBlockDeepak it didn't look like this was moving so I added the original test described above, confirmed it failed, adapted the code that reported the error, and pushed that to this branch. I snuck in a few minor cleanups I hit after merging main onto this branch. |
@ntjohnson1 Is this ready for review? There was a lingering review request from @DeepBlockDeepak, so it wasn't clear to me if your changes are ready for the merge now. |
@dmdunla yes it is ready. There were no changes on the branch after the bad merge. I mostly just mentioned him since he opened the PR initially |
Tensor data with invalid indices relative to shape, in file
sptensor2.tns
:New Behavior when loading faulty tensor data:
📚 Documentation preview 📚: https://pyttb--207.org.readthedocs.build/en/207/