ToDiscretePointSet
This commit is contained in:
		
							parent
							
								
									f49697b64a
								
							
						
					
					
						commit
						c2b90b7023
					
				|  | @ -33,6 +33,7 @@ | |||
|       "from": { | ||||
|         "data": "con" | ||||
|       }, | ||||
|       "interpolate": "linear", | ||||
|       "encode": { | ||||
|         "update": { | ||||
|           "x": { | ||||
|  | @ -51,7 +52,7 @@ | |||
|             "value": "#4C78A8" | ||||
|           }, | ||||
|           "interpolate": { | ||||
|             "value": "monotone" | ||||
|             "value": "linear" | ||||
|           }, | ||||
|           "fillOpacity": { | ||||
|             "value": 1 | ||||
|  |  | |||
|  | @ -64,6 +64,22 @@ module Prepare = { | |||
|         values->ToValueArray.Record.twoArgs->E.R.bind(twoDistOrNumber) | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   module ToArrayRecordPairs = { | ||||
|     let twoArgs = (input: t): result<(array<ts>), err> => { | ||||
|       let array = input->ToValueArray.Array.openA | ||||
|       let pairs = | ||||
|         array->E.R.bind(pairs => | ||||
|           pairs | ||||
|           ->E.A2.fmap(xyCoord => | ||||
|             [xyCoord] | ||||
|             ->ToValueArray.Record.twoArgs | ||||
|           ) | ||||
|           ->E.A.R.firstErrorOrOpen | ||||
|         ) | ||||
|       pairs | ||||
|     } | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| module Process = { | ||||
|  |  | |||
|  | @ -30,22 +30,13 @@ module Declaration = { | |||
|   } | ||||
| } | ||||
| 
 | ||||
| let registry = [ | ||||
|   Function.make( | ||||
|     ~name="toContinuousPointSet", | ||||
|     ~definitions=[ | ||||
|       FnDefinition.make( | ||||
|         ~name="toContinuousPointSet", | ||||
|         ~inputs=[FRTypeArray(FRTypeRecord([("x", FRTypeNumeric), ("y", FRTypeNumeric)]))], | ||||
|         ~run=(inputs, _) => { | ||||
| let inputsTodist = (inputs: array<FunctionRegistry_Core.frValue>, makeDist) => { | ||||
|   let array = inputs->E.A.unsafe_get(0)->Prepare.ToValueArray.Array.openA | ||||
|   let xyCoords = | ||||
|     array->E.R.bind(xyCoords => | ||||
|       xyCoords | ||||
|       ->E.A2.fmap(xyCoord => | ||||
|                 [xyCoord] | ||||
|                 ->Prepare.ToValueArray.Record.twoArgs | ||||
|                 ->E.R.bind(Prepare.ToValueTuple.twoNumbers) | ||||
|         [xyCoord]->Prepare.ToValueArray.Record.twoArgs->E.R.bind(Prepare.ToValueTuple.twoNumbers) | ||||
|       ) | ||||
|       ->E.A.R.firstErrorOrOpen | ||||
|     ) | ||||
|  | @ -53,10 +44,29 @@ let registry = [ | |||
|     xyCoords | ||||
|     ->E.R.bind(r => r->XYShape.T.makeFromZipped->E.R2.errMap(XYShape.Error.toString)) | ||||
|     ->E.R2.fmap(r => ReducerInterface_ExpressionValue.EvDistribution( | ||||
|               PointSet(Continuous(Continuous.make(r))), | ||||
|       PointSet(makeDist(r)), | ||||
|     )) | ||||
|   expressionValue | ||||
|         }, | ||||
| } | ||||
| 
 | ||||
| let registry = [ | ||||
|   Function.make( | ||||
|     ~name="toContinuousPointSet", | ||||
|     ~definitions=[ | ||||
|       FnDefinition.make( | ||||
|         ~name="toContinuousPointSet", | ||||
|         ~inputs=[FRTypeArray(FRTypeRecord([("x", FRTypeNumeric), ("y", FRTypeNumeric)]))], | ||||
|         ~run=(inputs, _) => inputsTodist(inputs, r => Continuous(Continuous.make(r))), | ||||
|       ), | ||||
|     ], | ||||
|   ), | ||||
|   Function.make( | ||||
|     ~name="toDiscretePointSet", | ||||
|     ~definitions=[ | ||||
|       FnDefinition.make( | ||||
|         ~name="toDiscretePointSet", | ||||
|         ~inputs=[FRTypeArray(FRTypeRecord([("x", FRTypeNumeric), ("y", FRTypeNumeric)]))], | ||||
|         ~run=(inputs, _) => inputsTodist(inputs, r => Discrete(Discrete.make(r))), | ||||
|       ), | ||||
|     ], | ||||
|   ), | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user