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

Can't length an nx1 matrix #156

Closed
ghost opened this issue Jul 25, 2011 · 5 comments
Closed

Can't length an nx1 matrix #156

ghost opened this issue Jul 25, 2011 · 5 comments
Labels
speculative Whether the change will be implemented is speculative

Comments

@ghost
Copy link

ghost commented Jul 25, 2011

To keep code vector-matrix compatible must do size(v)[1], which works for both. Desirable?

@StefanKarpinski
Copy link
Member

I would argue that you shouldn't be calling length on non-vectors. Can you give an example where you need to do this?

@ghost
Copy link
Author

ghost commented Jul 26, 2011

My feeling is that as a convention you should not have to remember if
something is an nx1 matrix or a vector in any circumstance.

On Mon, Jul 25, 2011 at 9:44 PM, StefanKarpinski <
[email protected]>wrote:

I would argue that you shouldn't be calling length on non-vectors. Can you
give an example where you need to do this?

Reply to this email directly or view it on GitHub:
#156 (comment)

@StefanKarpinski
Copy link
Member

I'm not sure I quite buy into that. I'd like to see more examples before we commit to this either way. Matlab defines it as

length(a::AbstractArray) = max(size(a))

I suppose we could go with that, but it seems wrong. Especially because we enumerate all of the items in an array when using it as an iterator, and the convention for iterable objects is that length for indexable, iterable objects give the maximum index so that

for x=a
  println(x)
end

will produce the same output as this:

for i=1:length(a)
  println(a[i])
end

That would also work for 1xn and mx1 "vectors". This basically means defining

length(a::AbstractTensor) = numel(a)

@JeffBezanson
Copy link
Member

Yes, given linear indexing I suppose length == numel makes sense.

@StefanKarpinski
Copy link
Member

Yeah, ok. I'm cool with that.

StefanKarpinski pushed a commit that referenced this issue Feb 8, 2018
modify path for tests that shell out on windows
cmcaine pushed a commit to cmcaine/julia that referenced this issue Sep 24, 2020
* CI: Bump tested Julia version

* Change Windows, too
LilithHafner pushed a commit to LilithHafner/julia that referenced this issue Oct 11, 2021
KristofferC pushed a commit that referenced this issue Aug 25, 2023
Stdlib: Tar
URL: https://github.com/JuliaIO/Tar.jl.git
Stdlib branch: master
Julia branch: master
Old commit: ff55460
New commit: 81888a3
Julia version: 1.11.0-DEV
Tar version: 1.10.0 (Does not match)
Bump invoked by: @DilumAluthge
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
JuliaIO/Tar.jl@ff55460...81888a3

```
$ git log --oneline ff55460..81888a3
81888a3 Correct some typos (#159)
a82ddde Fix some issues found by JET (#162)
6c51ea7 Give hint about possible insufficient storage on error message (#161)
84e6571 minimize impact of invalidations due to uninferred `ctx` (#158)
b0b8ec7 Merge pull request #157 from JuliaIO/dependabot/github_actions/actions/checkout-3
24bb56d Merge pull request #156 from JuliaIO/dependabot/github_actions/codecov/codecov-action-3
9f7d944 Merge pull request #155 from JuliaIO/dependabot/github_actions/actions/cache-3
d14feb4 Bump actions/checkout from 2 to 3
f149f85 Bump codecov/codecov-action from 1 to 3
ea228f2 Bump actions/cache from 1 to 3
4b54b0c Merge pull request #153 from ranocha/hr/dependabot
c70adcb enable dependabot for GitHub actions
cf089ab fix some sources of invalidations (#152)
```

Co-authored-by: Dilum Aluthge <[email protected]>
Keno pushed a commit that referenced this issue Oct 9, 2023
* ensure we leave wrapper if we step to the end of it
vtjnash pushed a commit that referenced this issue Dec 8, 2023
Stdlib: Statistics
URL: https://github.com/JuliaStats/Statistics.jl.git
Stdlib branch: master
Julia branch: jn/loading-stdlib-exts
Old commit: 04e5d89
New commit: 68869af
Julia version: 1.11.0-DEV
Statistics version: 1.11.1(Does not match)
Bump invoked by: @vtjnash
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
JuliaStats/Statistics.jl@04e5d89...68869af

```
$ git log --oneline 04e5d89..68869af
68869af Bump patch for version 1.11.1
89f5fc7 Create tagbot.yml
dc844db CI: restore v1.9.4 to build matrix (#159)
d0523ae relax test for mapreduce_empty (#156)
d1c1c42 Drop support for v1.9 in CI (#157)
bfc6326 Fix `quantile` with `Date` and `DateTime` (#153)
b8ea3d2 Prevent overflow in `mean(::AbstractRange)` and relax type constraint. (#150)
a88ae4f Document MATLAB behavior in `quantile` docstring (#152)
46290a0 Revert "Prepare standalone package, step 2 (#128)" (#148)
81a90af make SparseArrays a weak dependency (#134)
```

Co-authored-by: Dilum Aluthge <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
speculative Whether the change will be implemented is speculative
Projects
None yet
Development

No branches or pull requests

3 participants