@@ -7,6 +7,95 @@ importScripts(
7
7
const parser = math . parser ( )
8
8
const digits = 14
9
9
10
+ function createNewHelp ( ) {
11
+ const oldHelp = math . help
12
+ const newDocs = {
13
+ props : {
14
+ name : 'props' ,
15
+ category : 'physics' ,
16
+ description : 'Get properties of pure fluids, pseudo-pure fluids and mixtures according to coolprop.' ,
17
+ syntax : [
18
+ "props(desired property, name of fluid, an object with two physical properties)"
19
+ ] ,
20
+ examples : [
21
+ "props('D','Water',{T:0 degC,'P|liquid':1atm })" ,
22
+ "props('D', 'CO2', {T:298.15 K, P:100e5 Pa})"
23
+ ] ,
24
+ seealso : [ 'HAprops' , 'phase' , 'MM' ]
25
+ } ,
26
+ HAprops : {
27
+ name : 'HAprops' ,
28
+ category : 'physics' ,
29
+ description : 'Get properties of pure humid air according to coolprop.' ,
30
+ syntax : [
31
+ "HAprops(desired property, an object with three physical properties)"
32
+ ] ,
33
+ examples : [
34
+ "HAprops('H',{T:298.15 K, P:101325 Pa, R:0.5})" ,
35
+ "HAprops('T',{P:1 atm, H:50 kJ/kg, R:1.0})" ,
36
+ "HAprops('T',{H: 50 kJ/kg, R:50%, P:1 atm})"
37
+ ] ,
38
+ seealso : [ 'props' , 'phase' , 'MM' ]
39
+ } ,
40
+ phase : {
41
+ name : 'phase' ,
42
+ category : 'physics' ,
43
+ description : 'Get the phase of pure fluids, pseudo-pure fluids and mixtures according to coolprop.' ,
44
+ syntax : [
45
+ "phase( name of fluid, an object with two physical properties)"
46
+ ] ,
47
+ examples : [
48
+ "phase('Water',{T:0 degC,'P|liquid':1atm })" ,
49
+ "phase('CO2', {T:298.15 K, P:100e5 Pa})"
50
+ ] ,
51
+ seealso : [ 'props' , 'HAprops' , 'MM' ]
52
+ } ,
53
+ MM : {
54
+ name : 'MM' ,
55
+ category : 'chemistry' ,
56
+ description : 'Get the molecular mass of a chemical formula and a list of properties.' ,
57
+ syntax : [
58
+ "MM(chemical formula)"
59
+ ] ,
60
+ examples : [
61
+ "water = MM('H2O')" ,
62
+ "water.fraction.O" ,
63
+ "MM('C6H12O6')"
64
+ ] ,
65
+ seealso : [ 'props' , 'HAprops' , 'phase' ]
66
+ } ,
67
+ plot : {
68
+ name : 'plot' ,
69
+ category : 'plotting' ,
70
+ description : 'Create a plot according to ploty syntax.' ,
71
+ syntax : [
72
+ "plot(data, layout, config)" ,
73
+ "plot(data, layout)" ,
74
+ "plot(data)"
75
+ ] ,
76
+ examples : [
77
+ "plot([{x: [1, 2, 3], y: [2, 1, 3]}])" ,
78
+ "plot([{x: [1, 2, 3], y: [2, 1, 3]}], {title: 'My plot'})" ,
79
+ "plot([{x: [1, 2, 3], y: [2, 1, 3]}], {title: 'My plot'}, {responsive: true})"
80
+ ] ,
81
+ seealso : [ 'sin' , 'cos' , 'tan' ]
82
+ }
83
+ }
84
+
85
+ return function help ( x ) {
86
+ const nameString = typeof x === 'function' ? x . name : x
87
+ if ( nameString in newDocs ) {
88
+ return new math . Help ( newDocs [ nameString ] )
89
+ } else {
90
+ return oldHelp ( x )
91
+ }
92
+ }
93
+ }
94
+
95
+ math . import ( {
96
+ help : createNewHelp ( )
97
+ } , { override : true } )
98
+
10
99
/**
11
100
* Applies a given function to each element of an array or matrix.
12
101
*
@@ -32,13 +121,13 @@ const functionsToVectorize =
32
121
math . import (
33
122
{
34
123
props, HAprops, phase, MM ,
35
- plot : math . typed ( {
124
+ plot : math . typed ( 'plot' , {
36
125
'Array, Object, Object' : plot ,
37
126
'Array, Object' : ( data , layout ) => plot ( data , layout , { } ) ,
38
127
'Array' : data => plot ( data , { } , { } ) ,
39
128
} ) ,
40
129
...Object . fromEntries ( functionsToVectorize . map ( f => [ f , mapped ( math [ f ] ) ] ) ) ,
41
- log : math . typed ( {
130
+ log : math . typed ( 'log' , {
42
131
'Array | Matrix' : x => math . map ( x , x1 => math . log ( x1 , math . e ) ) ,
43
132
'Array | Matrix, number' : ( x , base ) => math . map ( x , x1 => math . log ( x1 , base ) )
44
133
} )
0 commit comments