Alphaharrius / Zipper.jl

Implementation of Zipper Entanglement Renormalization on Julia platform.
GNU General Public License v3.0
1 stars 0 forks source link

Avoid the use of `iter|>first|>....` to extract information of an iterator. #27

Closed Alphaharrius closed 8 months ago

Alphaharrius commented 8 months ago

Description

Since Julia does not provide a good implementation of eltype which only return the type T of the Array{T}, if somehow Julia evaluated T as Any, the eltype will return Any. Thus we have used iter|>first|>typeof to check for the element type in a given iterator as a workaround. Yet this is shown to be faulty if the given iterating the given iterator is stateful, such as iterator type of Iterators.Stateful or the iterator is a generator which invoke generating functions that mutate some states.

Guidlines

Please locate all functions that uses iter|>first|>... to extract iterator element information across the entire codebase and change to other ways that does not implicitly induce state change.

Alphaharrius commented 8 months ago

Checked there are only one location that have such issue, which is one of the constructor of the new Subset which uses T::Type = iter|>first|>typeof to evaluate the type of the iterator's elements. It is now changed to getting from the generated ordering dictionary.

Other locations that have similar approach are all fetching information from function-scoped non-lazy iterators.