1. camlspotter
  2. opycaml

Commits

camlspotter  committed b348d29

operator $ => %, since % is Percentile and P is for Python!

  • Participants
  • Parent commits ca4544e
  • Branches dev

Comments (0)

Files changed (2)

File api.ml

View file
  • Ignore whitespace
   val ( !:> ) : [> _Object ] t -> _Object t
     (** Coercing an object to _Object t *)
 
-  val ( $. ) : [> _Object ] t -> string -> _Object t
+  val ( %. ) : [> _Object ] t -> string -> _Object t
     (** Attribute access. Python's o.x *)
 
-  val ( $<> ) : [> _Dict ] t -> string -> _Object t
+  val ( %<> ) : [> _Dict ] t -> string -> _Object t
     (** Dictionary access. Python's o[x] *)
 
-  val ( $ ) : [> _Object ] t -> string -> _Object t
+  val ( % ) : [> _Object ] t -> string -> _Object t
     (** Attribute/Dictionary access by string. *)
 
   val call : [> _Object ] t -> [> _Object ] t list -> _Object t
 end = struct
   (* Some useful tools available by open Api *)
   let ( !:> ) o = (o :> _Object t)
-  let ( $. ) = Object.getAttrString (* Python's o.x *)
-  let ( $<> ) = Dict.getItemString (* Python's o[x] *)
-  let ( $ ) = Object.getByString
+  let ( %. ) = Object.getAttrString (* Python's o.x *)
+  let ( %<> ) = Dict.getItemString (* Python's o[x] *)
+  let ( % ) = Object.getByString
   let call o = Object.call (Callable.coerce o)
   let kwd_call o = Object.kwd_call (Callable.coerce o)
   let show_error typ detail = Printf.sprintf "%s: %s" (Py.String.asString (Object.str typ)) (Py.String.asString (Object.str detail))

File examples/matplotlib/finance_demo.ml

View file
  • Ignore whitespace
   (* import datetime *)
   let datetime = import_module "datetime" in
 
-  let date = call (datetime $ "date") in
+  let date = call (datetime % "date") in
 
   (* date1 = datetime.date( 2004, 2, 1) *)
   let date1 = date [ Int.fromLong 2004; Int.fromLong 2; Int.fromLong 1 ] in
         debug detail "detail";
   end;
 
-  let monday = dates $ "MONDAY" in
+  let monday = dates % "MONDAY" in
   debug monday "monday";
 
-  let dayLocator = dates $ "DayLocator" in
+  let dayLocator = dates % "DayLocator" in
   debug dayLocator "DayLocator";
 
   (* Class can be called as a function for New *)
-  let dayLocator_f = call (dates $ "DayLocator") in
+  let dayLocator_f = call (dates % "DayLocator") in
 
   let alldays = dayLocator_f [] in
   debug alldays "alldays";
 
-  let weekdayLocator = call (dates $ "WeekdayLocator") in
+  let weekdayLocator = call (dates % "WeekdayLocator") in
 
   let mondays = weekdayLocator [ monday ] in
 
-  let dateFormatter = call (dates $ "DateFormatter") in
+  let dateFormatter = call (dates % "DateFormatter") in
 
   let weekFormatter = dateFormatter [ Py.String.fromString "%b %d" ] in
   debug weekFormatter "weekFormatter";
   let dayFormatter = dateFormatter [ Py.String.fromString "%d" ] in
   debug dayFormatter "dayFormatter";
 
-  let quotes_historical_yahoo = call (finance $ "quotes_historical_yahoo") in
-  debug (finance $ "quotes_historical_yahoo") "quotes_historical_yahoo";
+  let quotes_historical_yahoo = call (finance % "quotes_historical_yahoo") in
+  debug (finance % "quotes_historical_yahoo") "quotes_historical_yahoo";
  
   let quotes = 
     try
 
   debug quotes "quotes";
 
-  let fig = call (pylab $ "figure") [] in
+  let fig = call (pylab % "figure") [] in
   debug fig "fig";
 
   (* CR jfuruse: warnings for unit cases. lousy... *)
-  kwd_call (fig $ "subplots_adjust") [ "bottom", Float.fromDouble 0.2];
-  let ax = call (fig $ "add_subplot") [ Int.fromLong 111 ] in
+  kwd_call (fig % "subplots_adjust") [ "bottom", Float.fromDouble 0.2];
+  let ax = call (fig % "add_subplot") [ Int.fromLong 111 ] in
   debug ax "ax";
 
-  call (ax $ "xaxis" $ "set_major_locator") [ mondays ];
-  call (ax $ "xaxis" $ "set_minor_locator") [ alldays ];
-  call (ax $ "xaxis" $ "set_major_formatter") [ weekFormatter ];
-  (* call (ax $ "xaxis" $ "set_minor_formatter") [ dayFormatter ]; *)
+  call (ax % "xaxis" % "set_major_locator") [ mondays ];
+  call (ax % "xaxis" % "set_minor_locator") [ alldays ];
+  call (ax % "xaxis" % "set_major_formatter") [ weekFormatter ];
+  (* call (ax % "xaxis" % "set_minor_formatter") [ dayFormatter ]; *)
 
   (* #plot_day_summary(ax, quotes, ticksize=3) *)
-  kwd_call (finance $ "candlestick") [ "", ax; "", quotes; "width", !:> (Float.fromDouble 0.6) ];
+  kwd_call (finance % "candlestick") [ "", ax; "", quotes; "width", !:> (Float.fromDouble 0.6) ];
 
-  call (ax $ "xaxis_date") [];
-  call (ax $ "autoscale_view") [];
+  call (ax % "xaxis_date") [];
+  call (ax % "autoscale_view") [];
   
-  kwd_call (pylab $ "setp")
-    [ "", call (call (pylab $ "gca") [] $ "get_xticklabels") []; 
+  kwd_call (pylab % "setp")
+    [ "", call (call (pylab % "gca") [] % "get_xticklabels") []; 
       "rotation", !:> (Int.fromLong 45); 
       "horizontalalignment", !:> (Py.String.fromString "right") ];
 
-  call (pylab $ "show") [];
+  call (pylab % "show") [];
 
   ()