stdlib icon indicating copy to clipboard operation
stdlib copied to clipboard

refactor: use `stdlib` equivalent instead of built-in, fix indentation in `math/base/special/ldexp`

Open gunjjoshi opened this issue 1 year ago • 9 comments

Description

What is the purpose of this pull request?

This pull request:

  • replaces the use of built-in pow with stdlib_base_pow.
  • fixes indentation in example.c.

Related Issues

Does this pull request have any related issues?

None.

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

gunjjoshi avatar Aug 12 '24 10:08 gunjjoshi

This error in examples comes even without applying the changes in this PR. I'll have a look on ldexp to find out the problem.

gunjjoshi avatar Aug 12 '24 12:08 gunjjoshi

The error message comes as:

example.c:20:10: fatal error: 'stdlib/math/base/special/ldexp.h' file not found
#include "stdlib/math/base/special/ldexp.h"

even though the header files looks correct.

gunjjoshi avatar Aug 12 '24 12:08 gunjjoshi

@gunjjoshi Looks like ldexp is missing from the manifest.json' dependencies in the example configuration.

Planeshifter avatar Aug 12 '24 12:08 Planeshifter

@gunjjoshi Looks like ldexp is missing from the manifest.json' dependencies in the example configuration.

@Planeshifter For other packages too, we do not include the package's path in the example configuration of manifest.json, right? That is included directly from the header file inside the package. Still, I tried after including that, but the condition was the same.

gunjjoshi avatar Aug 12 '24 12:08 gunjjoshi

@gunjjoshi Yeah, the package itself shouldn't be listed as a dependency under its own configuration. I was mistakenly under the impression that the failure was caused in a different package's example. Not clear to me what's going on right now... Also seeing failures loading different modules in the CI checks here.

Planeshifter avatar Aug 12 '24 12:08 Planeshifter

@gunjjoshi @stdlib/number/float32/base/to-word seems wrong as a dependency in manifest.json. We need @stdlib/number/float64/base/to-words, I think.

Planeshifter avatar Aug 12 '24 13:08 Planeshifter

@Planeshifter It doesn't seem we have used that package anywhere in ldexp. We should remove that.

gunjjoshi avatar Aug 12 '24 13:08 gunjjoshi

We have used float64/base/to_words in main.c, but we listed float32/base/to_word in manifest.json. Even after rectifying that, the error persists.

gunjjoshi avatar Aug 12 '24 13:08 gunjjoshi

After looking into this a bit more, I noticed that running the C examples for @stdlib/math/base/special/pow is failing as well.

Running the examples with DEBUG=library-manifest:main, it looks to me as if we have a cycle here and @stdlib/utils/library-manifest may not be handling those yet?

cc @kgryte

Planeshifter avatar Aug 13 '24 14:08 Planeshifter

/stdlib merge

kgryte avatar Nov 25 '24 06:11 kgryte

Coverage Report

Package Statements Branches Functions Lines
math/base/special/ldexp $\color{green}279/279$
$\color{green}+100.00\%$
$\color{green}18/18$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}279/279$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this PR.

stdlib-bot avatar Nov 25 '24 06:11 stdlib-bot

it looks to me as if we have a cycle here and @stdlib/utils/library-manifest may not be handling those yet?

That's correct. We cannot handle cyclic dependencies in C implementations. In this case, I think it would be fine to refactor the example in order to avoid the use of math/base/special/pow. Perhaps instead of randomly generating exponents in a loop, we can simply hardcode 3-4 examples (sign, frac, exp, etc) to show roundtripping. Does that sound reasonable, @gunjjoshi?

kgryte avatar Nov 25 '24 07:11 kgryte

@kgryte Yes, that does. I'll update the examples accordingly, thanks!

gunjjoshi avatar Nov 25 '24 08:11 gunjjoshi

Updated the C examples. Also, updated benchmarks to follow latest conventions.

gunjjoshi avatar Nov 25 '24 17:11 gunjjoshi

The CI failure seems to occur due to the failure in cephes benchmarks, as it is unable to find cephes files.

gunjjoshi avatar Nov 25 '24 17:11 gunjjoshi

The CI failure seems to occur due to the failure in cephes benchmarks

@Planeshifter I forget. Did we not already address the Cephes build issue?

kgryte avatar Nov 26 '24 00:11 kgryte

@kgryte I don't recall us addressing the Cephes build errors.

Planeshifter avatar Nov 26 '24 00:11 Planeshifter

PR Commit Message

bench: update benchmarks and examples in `math/base/special/ldexp`

PR-URL: https://github.com/stdlib-js/stdlib/pull/2781

Co-authored-by: stdlib-bot <[email protected]>
Reviewed-by: Athan Reines <[email protected]>
Signed-off-by: Gunj Joshi <[email protected]>

Please review the above commit message and make any necessary adjustments.

stdlib-bot avatar Nov 26 '24 00:11 stdlib-bot

As the CI failure is due to an upstream workflow failure and not due to the changes in this PR, I will go ahead and merge.

kgryte avatar Nov 26 '24 01:11 kgryte