Wolfram Integration
Closed this issue · 2 comments
I am having some trouble integrating the Mathematica code into ESCALATE.
Specifically, the code is failing from within Wolfram itself. Instead of returning a dictionary, it is returning a string representation of a Mathematica function, which it seems to do when its fed something it doesn't like. The problem is, I can't tell what I'm feeding it that is substantively different than the input it got in the attached IPython notebook.
I integrated the WLS file with the wrapper defined here:
Forgive the gratuitous object orientation: my aim was to keep the WolframLanguageSession
object out of the global scope but let it persist over time.
The method defined here:
is intended to keep Wolfram from silently failing when passed int
s instead of float
s, which is a problem I had earlier. If you want, you can ignore this method for debugging purposes and instead use the private method defined here:
which, notably, should work exactly the same as the function I defined in the IPython notebook (attached).
Sanity checks I have already performed:
- This line prints out the global scope in the Mathematica session. It should contain all of the functions that Josh defined, and as far as I can tell it does.
- I switched to using the private method
WolframSampler._generateExperiments()
discussed above, but I still get the error.
ESCALATE_Capture/capture/generate/qrandom.py
Line 281 in 0cd3756
Moving forward:
The code as currently written prints a bunch of stuff you might want to see, including the dict of the vector representations of the reagents, and the Wolfram output. Attached is a zip containing the IPython notebook where the Mathematica code works. I would start debugging this by triple checking that I didn't do something that doesn't match the implementation in the notebook. As far as I can tell I haven't but, perhaps someone who isn't me will be able to catch my own subtle mistake.
Attachment:
Note: the output I'm getting from the code on my local is
Obtaining chemical information from Google Drive..
Functions defined in Wolfram session:
['allowedExperiments', 'allowedHull', 'compositionBoundary', 'compositionBoundary$', 'convertConcentrationsToVolumes', 'correctDimensionalityVector', 'correctDimensionalityVector$', 'd', 'd$', 'experiments', 'finalVolume', 'generateExperiments', 'hull', 'hull$', 'imposedBoundary', 'imposedBoundary$', 'maxConcentration', 'maxMolarity', 'minConcentration', 'nExpt', 'nExpts', 'processValues', 'reagentDefs', 'reagentNames', 'reagentNames$', 'reagents', 'sampleConcentrations', 'space', 'space$', 'stocks', 'stocks$', 'v', 'v$', 'x', '$MinVersionSupported', '$NotSupportedVersionErrNo']
Reagent vectors:
{'Reagent1 (ul)': [0, 0, 0],
'Reagent2 (ul)': [2.85, 0, 2.28],
'Reagent3 (ul)': [4.18, 0, 0]}
Wolfram output:
Times[500.0, Global`convertConcentrationsToVolumes[{'Reagent2 (ul)': [3, 0, 2], 'Reagent3 (ul)': [4, 0, 0], 'Reagent1 (ul)': [0, 0, 0]}, Round[Global`sampleConcentrations[BoundaryDiscretizeRegion[BooleanRegion[Function[And[Slot[1], Slot[2]]], [MeshRegion[[[2.85, 0.0, 2.28], [4.18, 0.0, 0.0], [0.0, 0.0, 0.0]], [Polygon[[[1, 2, 3]]]], Rule[Method, [Rule['EliminateUnusedCoordinates', True], Rule['DeleteDuplicateCoordinates', Automatic], Rule['DeleteDuplicateCells', Automatic], Rule['VertexAlias', Identity], Rule['CheckOrientation', Automatic], Rule['CoplanarityTolerance', Automatic], Rule['CheckIntersections', Automatic], Rule['BoundaryNesting', Automatic], Rule['SeparateBoundaries', Automatic], Rule['TJunction', Automatic], Rule['PropagateMarkers', True], Rule['ZeroTest', Automatic], Rule['Hash', 5359314806790543420]]]], Cuboid[[0, 0, 0], [9.0, 9.0, 9.0]]]]], 96]]]]