Implement a `unique` function returning only the unique values in a vector.
Nessuno ha ancora preso questa issue.
- #965 di @demoncoder-crypto — chiusa senza merge
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- fortran
- Ambito
- data
Direzione di ricerca
Start by checking whether stdlib already provides a suitable function, as the issue asks. The proposed starting scope is a unique function for one dimensional integer, real, complex, and character vectors, with optional sorting; the issue does not identify files or tests. Define and agree on the supported cases and behavior before implementation, then verify the result covers the agreed scope.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Motivation
Recently, I've run into the problem of extracting unique values in a vector (of any integer, real or complex type or possibly even character). Consider for instance the following vector x = [1, 2, 3, 3, 4]. What I'd need is a function taking x as input and returning the vector y = [1, 2, 3, 4] as output. The interface for a real-valued vector could be as simple as
pure function unique(x, sorted) result(y)
real(dp), intent(in) :: x(:)
!! Array whose unique values need to be extracted.
logical(lk), optional, intent(in) :: sorted
!! Whether the output vector needs to be sorted or not (default .false. ?)
real(dp), allocatable :: y(:)
!! Vector containing only the unique values from x.
end function
The output vector could be sorted or not, depending on the user's choice. I know that there are no Fortran intrinsic functions for that purpose, but I ain't sure something like that is already available in stdlib. If I'm wrong, could anyone point me to the correct function?
Prior Art
- In Matlab, there is the
uniquefunction whose description is available here. - Python has the
setfunction taking as input alistand returning only the unique elements of this list. - Numpy has
np.uniquewhose description is available here. - @jacobwilliams provides an integer-based implementation on his blog (here).
Additional Information
Both Matlab and Numpy's implementations cover a relatively large set of cases (1D-array, multidimensional arrays, different types, etc) and return values (the unique elements, the corresponding indices, indices to the reconstruct the original array from this unique set, etc).
I don't know if absolutely all these cases need to be covered (at least as a starting point). I would probably recommend to start with the simplest ones (i.e. only input vectors and output vector with the unique elements) as these are probably the most common situations where a unique function might be needed. That would include integer, real, complex and character 1D-arrays.
- Lingua principale
- Fortran
- Stelle
- 1.4k
- Fork
- 233
- Merge medio
- 3g 6h
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di fortran-lang/stdlib
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
fortran-lang/stdlib#1193 · 5 commenti ·
-
Cannot compile example_mnorm.f90Forse già presa @Chaitanya-970 l’ha presa 1 giorno fa. Apertabug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
fortran-lang/stdlib#1224 · 4 commenti ·
-
LAPACK upgradesApertaidea topic: linalg
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
fortran-lang/stdlib#1199 · 1 reazione ·
-
Support meson build systemApertaidea
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
fortran-lang/stdlib#1181 · 2 commenti · 1 reazione ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 49/100
fortran-lang/stdlib#1178 · 3 commenti ·
Tutte le issue di fortran-lang/stdlib
Issue simili
-
Zero-size bag sampling raises instead of returning an empty BagForse già presa @AtharvRG l’ha presa oggi. Apertaneeds triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
dask/dask#12691 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Add: Cinemax Asia HDApertacheck:passed streams:add
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
bug help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 3 giorni
-
enhancement io
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
onthegomap/planetiler#1657 ·
I maintainer di solito rispondono entro 1 giorno