Skip to content

Conversation

@inetol
Copy link
Member

@inetol inetol commented Dec 5, 2025

Unit converter plugin no longer exists, it's now part of Calculator.

Screenshot

You can also perform operations with units:

Screenshot

Unknown plugins in settings.yml will softfail and not register.

*Unit converter* plugin no longer exists, it's now part of *Calculator*.
You can also perform operations with units.
@inetol inetol force-pushed the mod-themes-plugins2 branch from a450e30 to 44d4f5b Compare December 5, 2025 16:49
@return42 return42 self-requested a review December 6, 2025 07:19
@return42
Copy link
Member

return42 commented Dec 6, 2025

I'm not sure if it's a good idea to move the unit converter to the JS client. I see two disadvantages:

  1. No-JS clients will lose the unit converter function
  2. Compared to the (hard coded) unit system of mathjs, SearxNG's wikidata units are generic and updated regularly from wikidata / and thanks to wikidata, SearXNG has a more unit definitions.

Definition of Units (and the SI and non SI conversion factors) in MathsJS:

https://github.com/josdejong/mathjs/blame/4bbe862bb553bd765685b46d977e8ee226e4abf0/src/type/unit/Unit.js#L1649-L1657

Definitions of units (and the SI conversion factors) in SearXNG / generic generated from wikidata units ..

{
"Q100036106": {
"si_name": "Q11573",
"symbol": "int nmi",
"to_si_factor": 1852.0
},

@inetol
Copy link
Member Author

inetol commented Dec 6, 2025

  1. No-JS clients will lose the unit converter function

Unit conversion isn't a main feature on SearXNG, we can delegate this to be a client only thing.

  1. Compared to the (hard coded) unit system of mathjs, SearxNG's wikidata units are generic and updated regularly from wikidata / and thanks to wikidata, SearXNG has a more unit definitions.

It's broken because I can't convert anything other than distance units. Even then, now we can do expressions using these units (e.g., "1.3GiB * 53min"), and if needed, add new units based on other expressions.

@return42
Copy link
Member

return42 commented Dec 7, 2025

It's broken because I can't convert anything other than distance units.
Even then, now we can do expressions using these units (e.g., "1.3GiB * 53min"),

Sorry for being slow in uptake, not sure I fully understand you .. TBH I'm confused:

How is unit conversion related to a multiplication (or division) of units, like "1.3GiB * 53min" = "GiB min"? .. not related, but personally I know Bytes/time (GiB/s) what counts a performance value .. what isn't a request to convert units(!)

and if needed, add new units based on other expressions.

The Unit implementation of mathjs allows artihmetic operations on Unit objects (complex numbers?) by any other unit .. for mathematical operation on units, mathjs has implemented its own system of (physical and non physical) units such as meters or, for example, mass ..

On the oposite, the unit conversion in SearXNG is based on the International System of Units (aka SI).

In MathJS we have (for example) a unit (type) BASE_UNITS.SURFACE for .. in the SI System this is derived unit.

The SI knows about (the) seven base units .. apart from these seven base quantities, there are no other known physical quantities, which is why these are sufficient to perform conversions between the different unit systems (e.g. 20 °C to °F = 68 °F).

Unit conversion isn't a main feature on SearXNG,

Yeah, thats true .. SearXNG main feature are search results .. and the unit-converter is just a plugin, but ..

we can delegate this to be a client only thing.

.. isn't true , at least not for our no-JS clients.

As a graduate physicist, I prefer the SI system because it allows all physical unit of measure to be converted (with the help of Wikidata).

MathJS could be a plus if we want to handle other units of measure (non physical) like byte .. but that would be an addition to the existing solution (the server plugin based on SI).

.. or do I miss something?

@inetol
Copy link
Member Author

inetol commented Dec 7, 2025

How is unit conversion related to a multiplication (or division) of units, like "1.3GiB * 53min" = "GiB min"? .. not related, but personally I know Bytes/time (GiB/s) what counts a performance value .. what isn't a request to convert units(!)

I wrote wrongly. I meant to say, for example "(300 Mb/s + 980 kilobit/sec) to GB/hour", Previously, it was not possible to perform math and conversions of this type.

As a graduate physicist, I prefer the SI system because it allows all physical unit of measure to be converted (with the help of Wikidata).

MathJS could be a plus if we want to handle other units of measure (non physical) like byte .. but that would be an addition to the existing solution (the server plugin based on SI).

.. or do I miss something?

I can't tell much as I don't study this, but comparing units such as "acres" between the Wikidata db and the math.js UNITS object, they use the same factor (value property is the factor in math.js) with usually less precision in the latter.

@return42
Copy link
Member

return42 commented Dec 8, 2025

they use the same factor

If they used other factors, the results would be wrong ;-) . It is inherent in the nature of the task that the two solutions are similar. We generate our unit database from Wikidata, which receives corrections and additions every week. The database from MathJS was initially created 10 years ago and since then has been little corrected or supplemented. Accordingly, the Wikidata database is much more comprehensive / it contains far more symbols / respectively designations for physical quantities -> more conversion factors.

Here is just one example of a traditional unit ha converted to its (derived) SI unit

10ha to m²

(300 Mb/s + 980 kilobit/sec) to GB/hour

This is far more than a conversion .. To be precise, it isn't a unit conversion (its a operation with complex numbers / unit implementation seems to me similar to complex numbers): to GB/hour only converts the prefix from s to h and the prefix M to G. Explanation: compared to my example from above, we can take this example:

1 km² to m²

In this example the unit is m (SI unit for lenght) the request just wants to replace the prefix k --> its not a unit conversion, like shown above in the ha example.

But of course you're right, MathJS Units provide a useful additional value if we can perform such complex operations on the client / MathJS can provide us with enhancements, but it can't replace the existing (server-side Wikidata) solution / from my point, the arguments have not been refuted so far:

  1. No-JS clients will lose the unit converter function
  2. Compared to the (hard coded) unit system of mathjs, SearxNG's wikidata units are generic and updated regularly from wikidata / and thanks to wikidata, SearXNG has a more unit definitions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants