beta-effect / juxta.jl Goto Github PK
View Code? Open in Web Editor NEWMultidimensional arrays with labeled axes
License: MIT License
Multidimensional arrays with labeled axes
License: MIT License
Line 38 in 7162bef
Lines 14 to 29 in 7162bef
Was just wondering about a few things:
mutable
? Looks like the array contents may change but the struct itself won't so making it immutable might make more sense? You can append attributes as well, just not change what attribs
is. Also could help the compiler make certain optimizations as it knows the struct properties won't change.Symbol
s instead of String
s as the key. Not sure how helpful it would be for a labelled array but other packages like DataFrames.jl seem to use symbols. Might be a good read: https://stackoverflow.com/questions/23480722/what-is-a-symbol-in-julia@assert
but apparently in C/C++, Python, and Julia they seem more for checking developer mistakes and may actually be disabled by certain optimization levels. So might be better to throw exceptions or something else.Also, I might strongly type the struct
to get more flexible JuxtArray
(i.e. keys can be symbols or strings, types sort themselves out, indices don't need to be abstract ranges, etc.):
struct JuxtArray{A, D, C, AT, I}
array::A
dims::D
coords::C
attribs::AT
indices::I
end
or you can be a bit more specific if you want to:
struct JuxtArray{A<:AbstractArray, K, C, I}
array::A
dims::Vector{K}
coords::Dict{K, C}
attribs::Dict
indices::Dict{K, I}
end
If you include code examples in the README with
```julia <code>```
then you also get syntax highlighting which might make them a bit more readable.
Looks like you already have great docstrings. If you're interested in automatically turning it into documentation, check out https://github.com/JuliaDocs/Documenter.jl
should be Juxta.jl
.
Could probably dispatch on method
if it was a type or via the Val
type although I think the latter is discouraged.
Lines 89 to 109 in 7162bef
I'm probably just misunderstanding but I thought when you select part of a JuxtArray
, either through physical slicing or index-based slicing, that you would get back a new JuxtArray
containing just the selected portion, which shouldn't modify the existing JuxtArray
.
But it seems that these functions actually modify the existing JuxtArray
and overwrite ja.array
? Don't you lose data this way?
Lines 70 to 76 in 7162bef
can be rewritten as something like
push_dim!(ja, k, v::OrdinalRange) = push!(ja.indices, String(k) => v)
push_dim!(ja, k, v::Integer) = push!(ja.indices, String(k) => v:v)
...
String(k) in ja.dims && push_dim!(ja, k, v)
which should be easier to extend to other types of v
. It also seems to be the more Julian way of doing things.
If ja.dims
was of type Vector{Symbol}
you might be able to just use k
instead of String(k)
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.