Skip to content

Conversation

@BernhardAhrens
Copy link
Collaborator

@BernhardAhrens BernhardAhrens commented Dec 4, 2025

Needed to make this [row.nse.SOC for row in o_SOC.val_history] work

Otherwise I would need to do this
[row.nse.SOC for row in o_SOC.val_history.data]

The .data is not very intuitive. Does not affect train (I tested), not sure if this would affect anything else @lazarusA

end

# Required methods for AbstractVector
Base.size(w::WrappedTuples) = (length(w.data), length(first(w.data)))
Copy link
Member

@lazarusA lazarusA Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need this.

The intended use of this is to first do something like soc = WrappedTuples(SOC.history), and then soc.nse to get all values, without the need to use list comprehension.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

struct WrappedTuples{T <: AbstractVector{<:NamedTuple}} <: AbstractVector{NamedTuple}

It's also just odd to have an 2D vector 😆

@BernhardAhrens
Copy link
Collaborator Author

What do we need it for? train and the train_board works. For saving?

@BernhardAhrens
Copy link
Collaborator Author

When I do soc.nse, it is still a bit weird format which is not straightforward to extract (for me ;-))

11×5 Matrix{@NamedTuple{SOC::Float32, CQ::Float32, CB::Float32, mean::Float32}}:
 (SOC = -16210.9, CQ = -27.1608, CB = -55.532, mean = -5431.19)   (SOC = -16210.9, CQ = -27.1608, CB = -55.532, mean = -5431.19)   …  (SOC = -16210.9, CQ = -27.1608, CB = -55.532, mean = -5431.19)
 (SOC = -86.3123, CQ = -23.1424, CB = -59.6994, mean = -56.3847)  (SOC = -86.3123, CQ = -23.1424, CB = -59.6994, mean = -56.3847)     (SOC = -86.3123, CQ = -23.1424, CB = -59.6994, mean = -56.3847)```

@lazarusA
Copy link
Member

lazarusA commented Dec 5, 2025

What do we need it for? train and the train_board works. For saving?

is for convenient access of nested arrays of tuples.

your output from above could further be nse_t = WrappedTuples(soc.nse) and then nse_t.SOC to get the eleven values of SOC.

@BernhardAhrens
Copy link
Collaborator Author

Hmm, I do not see the convenience of doing this
WrappedTuples(WrappedTuples(o_SOC.train_history).nse).SOC (Is that what you meant?)
over
[i.nse.SOC for i in o_SOC.val_history]

Both work with my small change btw.

This also related to Andrés issue I think #174

I think we need some convenience functions for this. Maybe we have them already and I forgot 😃

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.

3 participants