10
1
mirror of https://gitlab.com/scemama/qmcchem.git synced 2024-12-21 11:53:30 +01:00

Changed List.map to List.rev_map

This commit is contained in:
Anthony Scemama 2020-04-15 14:40:33 +02:00
parent 81a329dbfb
commit 5deb4bef6b
10 changed files with 46 additions and 33 deletions

View File

@ -127,12 +127,11 @@ let update_raw_data ?(locked=true) () =
with
| End_of_file -> List.rev accu
in
List.map (fun filename ->
List.concat_map (fun filename ->
let ic = open_in filename in
let result = aux ic [] in
close_in ic;
result ) files
|> List.concat
|> transform []
in
result

View File

@ -840,7 +840,8 @@ end = struct
let read () =
List.map (fun x -> (x, Property.calc x)) Property.all
List.rev_map (fun x -> (x, Property.calc x)) Property.all
|> List.rev
let write l =
@ -848,17 +849,18 @@ end = struct
let to_string l =
List.map (fun (x,b) ->
List.rev_map (fun (x,b) ->
let ch =
if b then "X" else " "
in
Printf.sprintf "(%s) %s" ch (Property.to_string x)) l
|> List.rev
|> String.concat "\n"
let of_string s =
String.split_on_char '\n' s
|> List.map (fun x ->
|> List.rev_map (fun x ->
let (calc,prop) =
String.trim x
|> String_ext.rsplit2_exn ~on:' '
@ -874,6 +876,7 @@ end = struct
in
(prop, calc)
)
|> List.rev
end

View File

@ -56,7 +56,8 @@ let create m =
| (0,tail) ->
let result =
List.rev accu
|> List.map float_of_string
|> List.rev_map float_of_string
|> List.rev
|> Array.of_list
in
(result, tail)

View File

@ -111,8 +111,8 @@ let hash () =
in
let md5_string =
files_to_track
|> List.map (fun x -> Printf.sprintf "%s/%s" ezfio_filename x)
|> List.map hash_file
|> List.rev_map (fun x -> Printf.sprintf "%s/%s" ezfio_filename x)
|> List.rev_map hash_file
|> String.concat ""
in

View File

@ -231,7 +231,8 @@ let run ?(daemon=true) ezfio_filename =
Array.map Array.to_list walkers_array
|> Array.to_list
|> List.concat
|> List.map float_of_string
|> List.rev_map float_of_string
|> List.rev
in
Ezfio.set_electrons_elec_coord_pool (Ezfio.ezfio_array_of_list
~rank:3 ~dim:[| elec_num+1 ; 3 ; walk_num_tot |] ~data:walkers_list);
@ -631,7 +632,8 @@ let run ?(daemon=true) ezfio_filename =
Unix.gettimeofday ()
in
let msg =
List.map String.trim raw_msg
List.rev_map String.trim raw_msg
|> List.rev
|> Message.create
and msg_size =
List.fold_left (fun accu x -> accu + (String.length x)) 0 raw_msg
@ -716,7 +718,8 @@ let run ?(daemon=true) ezfio_filename =
Unix.gettimeofday ()
in
let msg =
List.map String.trim raw_msg
List.rev_map String.trim raw_msg
|> List.rev
|> Message.create
and msg_size =
List.fold_left (fun accu x -> accu + (String.length x)) 0 raw_msg

View File

@ -83,7 +83,7 @@ let create_temp_file ?temp_filename ezfio_filename fields =
| Some name -> name
in
let out_channel = open_out filename in
(file_header ezfio_filename) :: (List.map get fields)
(file_header ezfio_filename) :: (List.rev @@ List.rev_map get fields)
|> String.concat "\n"
|> output_string out_channel
; close_out out_channel
@ -210,10 +210,11 @@ let run ~c ?f ?t ?l ?m ?e ?et ?s ?ts ?w ?wt ?n ?j ?p ?input ezfio_filename =
in
let data =
( List.filter (fun x -> Str.string_match re_data x 0) raw_data
|> List.map String.trim ) @
|> List.rev_map String.trim |> List.rev ) @
[
List.filter (fun x -> Str.string_match re_prop x 0) raw_data
|> List.map String.trim
|> List.rev_map String.trim
|> List.rev
|> String.concat "\n" ]
in
let open Input in

View File

@ -309,7 +309,7 @@ let run ezfio_filename dataserver =
| head :: tail -> aux (head::header) tail
| _ -> failwith "Too many routers in the middle"
in
aux [] (List.map String.trim raw_msg)
aux [] (List.rev @@ List.rev_map String.trim raw_msg)
in
let handle message =
match message with
@ -401,7 +401,7 @@ let run ezfio_filename dataserver =
| head :: tail -> aux (head::header) tail
| _ -> failwith "Too many routers in the middle"
in
aux [] (List.map String.trim raw_msg)
aux [] (List.rev @@ List.rev_map String.trim raw_msg)
in
let handle message =
match message with

View File

@ -11,7 +11,8 @@ let display_table ~range property =
and data = p.Random_variable.data
in
let results =
List.map2 (fun (val1, err1) (val2,err2) -> (val1, err1, val2, err2)) conv rconv
List.rev_map2 (fun (val1, err1) (val2,err2) -> (val1, err1, val2, err2)) conv rconv
|> List.rev
in
List.iter2 (fun (val1, err1, val2, err2) block ->
Printf.printf "%10.6f %10.6f %10.6f %10.6f %10.6f\n"
@ -116,14 +117,15 @@ let display_histogram ~range property =
and norm =
1. /. (sqrt(sigma2 *. 2.*.pi))
in
List.map histo ~f:(fun (x,y) ->
List.rev_map histo ~f:(fun (x,y) ->
let g =
norm *. exp(-.((x-.mu)*.(x-.mu)*.one_over_2sigma2))
in
(x,y,g)
)
|> List.iter ~f:(fun (x,y,g) ->
Printf.printf "%16.10f %16.10f %16.10f\n" x y g)
|> List.rev
|> List.iter ~f:(fun (x,y,g) ->
Printf.printf "%16.10f %16.10f %16.10f\n" x y g)
*)

View File

@ -103,7 +103,8 @@ let full_run ?(start_dataserver=true) ezfio_filename =
in
match launcher
|> String.split_on_char ' '
|> List.map String.trim
|> List.rev_map String.trim
|> List.rev
|> List.filter (fun x -> x <> "")
with
| launcher_exe::launcher_flags ->

View File

@ -232,7 +232,7 @@ let ave_error { property ; data } =
in
if (Property.is_scalar property) then
List.map (fun x ->
List.rev_map (fun x ->
(Sample.to_float x.Block.value,
Weight.to_float x.Block.weight)
) data
@ -247,7 +247,7 @@ let ave_error { property ; data } =
in
let result =
Array.init dim (fun idx ->
List.map (fun x ->
List.rev_map (fun x ->
(Sample.to_float ~idx x.Block.value,
Weight.to_float x.Block.weight)
) list_of_samples
@ -429,7 +429,8 @@ let merge ~create_key ?update_block_id ?update_value ?update_weight t =
if (x>y) then 1
else if (x<y) then -1
else 0)
|> List.map (fun (x,y) -> y)
|> List.rev_map (fun (x,y) -> y)
|> List.rev
}
@ -505,7 +506,7 @@ let error_x_over_y = function
(** Create float, variable operators *)
let one_variable_operator ~update_value p f =
{ p with
data = List.map (fun b -> { b with
data = List.rev @@ List.rev_map (fun b -> { b with
Block.value = Sample.of_float (update_value (Sample.to_float b.Block.value) ) }
) p.data }
@ -594,7 +595,8 @@ let max_value_per_compute_node t =
if (x>y) then 1
else if (x<y) then -1
else 0)
|> List.map (fun (x,y) -> y)
|> List.rev_map (fun (x,y) -> y)
|> List.rev
}
@ -675,7 +677,8 @@ let compress_files () =
with
| Not_found -> true
)
|> List.map (fun x -> dir_name^x)
|> List.rev_map (fun x -> dir_name^x)
|> List.rev
in
let out_channel_dir =
@ -774,11 +777,11 @@ let centered_cumulants { property ; data } =
|> Average.to_float
in
let centered_data =
List.map (fun x ->
List.rev_map (fun x ->
( (Weight.to_float x.Block.weight),
(Sample.to_float x.Block.value) -. ave )
)
data
) data
|> List.rev
in
let var =
let (num, denom) =
@ -795,11 +798,11 @@ let centered_cumulants { property ; data } =
let sigma_inv =
1. /. (sqrt var)
in
List.map (fun x ->
List.rev_map (fun x ->
( (Weight.to_float x.Block.weight),
( (Sample.to_float x.Block.value) -. ave ) *. sigma_inv )
)
data
) data
|> List.rev
in
let (cum3,cum4) =
let (cum3, cum4, denom) =