Skip to content

Poisson geometric#1

Closed
JohanMabille wants to merge 25 commits into
ssam18:masterfrom
JohanMabille:poisson-geometric
Closed

Poisson geometric#1
JohanMabille wants to merge 25 commits into
ssam18:masterfrom
JohanMabille:poisson-geometric

Conversation

@JohanMabille
Copy link
Copy Markdown

Cherry-pick of last commit from xtensor-stack#2893, easier to do so than rebasing.

JohanMabille and others added 25 commits January 6, 2026 16:36
…ntainer (xtensor-stack#2880)

# Checklist

- [x] The title and commit message(s) are descriptive.
- [x] Small commits made to fix your PR have been squashed to avoid
history pollution.
- [x] Tests have been added for new features or bug fixes.
- [x] API of new functions and classes are documented.

# Description

The `index_mapper` class provides functionality to convert indices from
a view's coordinate system
to the corresponding indices in the underlying container. This is
particularly useful for views
that contain integral slices (fixed indices), as these slices reduce the
dimensionality of the view.

Example:
```cpp
xt::xarray<double> a = xt::arange(24).reshape({2, 3, 4});
auto view1 = xt::view(a, 1, xt::all(), xt::all());  // Fixed first dimension
index_mapper<decltype(view1)> mapper;

// Map view indices (i,j) to container indices (1,i,j)
double val = mapper.map(a, view1, 0, 0);  // Returns a(1, 0, 0)
double val2 = mapper.map(a, view1, 1, 2); // Returns a(1, 1, 2)
 ```

---------

Co-authored-by: Alexandre Hoffmann <alexandre.hoffmann@polytechnique.edu>
# Checklist

- [ ] The title and commit message(s) are descriptive.
- [ ] Small commits made to fix your PR have been squashed to avoid
history pollution.
- [ ] Tests have been added for new features or bug fixes.
- [ ] API of new functions and classes are documented.

# Description

<!---
Give any relevant description here.
If your PR fixes an issue, please include "Fixes #ISSUE" (substituting
the relevant issue ID).
-->
…or-stack#2889)

# Checklist

- [x] The title and commit message(s) are descriptive.
- [ ] Small commits made to fix your PR have been squashed to avoid
history pollution.
- [ ] Tests have been added for new features or bug fixes.
- [ ] ~~API of new functions and classes are documented.~~

# Description
This PR fixes an error pertaining to reading the length of the header of
an npy file. The header is read as two `char`s and then combined into a
`uint16_t`. Previously due to `char` being a signed value, any value
with the MSB set would get converted as if it were a negative number and
thus misinterpreted.

For example, the bytes `F6 00` which means a header of 246 bytes would
be interpreted as a header of 65526 bytes.

I think the code could be shortened a little, but I think when messing
with bits like this it's best to be explicit. Also, the compiler will
likely optimize it anyway.
…k#2891)

# Checklist

- [x] The title and commit message(s) are descriptive.
- [x] Small commits made to fix your PR have been squashed to avoid
history pollution.
- [x] Tests have been added for new features or bug fixes.
- [x] API of new functions and classes are documented.

# Description

The goal of this pullrequest is to fix thee error and warning during the
documentation generation.

---------

Co-authored-by: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com>
…tensor-stack#2871) (xtensor-stack#2882)

This PR addresses GitHub issue xtensor-stack#2871 where using auto with xtensor
reducer functions (like amax, sum with keep_dims) causes crashes or
incorrect results in optimized builds, particularly on Android ARM64.

**Root Cause:** Lazy expressions hold references to local variables.
When intermediate results are stored with auto, these references become
dangling when the function returns, leading to undefined behavior.

**Changes:**
- docs/source/pitfall.rst: Added detailed warning section explaining the
issue and providing three solutions:
  1. Use explicit container types (xt::xtensor<T, N>)
  2. Use xt::eval() to force immediate evaluation  
  3. Use evaluation_strategy::immediate with reducers
- test/test_xmath.cpp: Added test demonstrating correct patterns

**Testing:**
- All 83 xmath tests pass
- All 64 xreducer tests pass

Fixes xtensor-stack#2871
Commit generated through diskarzhan. 
With ci added to prevent regression.
This workaround is for old compilers not supported anymore.
Edit: `XTENSOR_CONSTEXPR_ENHANCED_STATIC` is still required on Windows.
# Checklist

- [x] The title and commit message(s) are descriptive.
- [x] Small commits made to fix your PR have been squashed to avoid
history pollution.
- [x] Tests have been added for new features or bug fixes.
- [x] API of new functions and classes are documented.

# Description

This PR fixes incorrect index mapping in xview assignments when a view
starts with one or more newaxis() slices.

The change updates the index computation to use a newaxis-aware slice
index before applying integral-slice adjustments. That keeps writes
through views with multiple leading newaxis() entries aligned with the
correct element in the underlying tensor.

Co-authored-by: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com>
# Checklist

- [x] The title and commit message(s) are descriptive.
- [x] Small commits made to fix your PR have been squashed to avoid
history pollution.
- [x] Tests have been added for new features or bug fixes.
- [x] API of new functions and classes are documented.

# Description

Add clang 22 and gcc 15 in the CI

---------

Co-authored-by: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com>
Co-authored-by: Copilot <copilot@github.com>
…stack#2909)

# Checklist

- [x] The title and commit message(s) are descriptive.
- [x] Small commits made to fix your PR have been squashed to avoid
history pollution.
- [x] Tests have been added for new features or bug fixes.
- [x] API of new functions and classes are documented.

# Description

Address xtensor-stack#2860 

Now `clips` follow the rule: When a_min is greater than a_max, clip
returns an array in which all values are equal to a_max

---------

Co-authored-by: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com>
Co-authored-by: Copilot <copilot@github.com>
# Checklist

- [x] The title and commit message(s) are descriptive.
- [x] Small commits made to fix your PR have been squashed to avoid
history pollution.
- [x] Tests have been added for new features or bug fixes.
- [x] API of new functions and classes are documented.

# Description

Add Linux ARM build on the CI

---------

Co-authored-by: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com>
# Checklist

- [x] The title and commit message(s) are descriptive.
- [x] Small commits made to fix your PR have been squashed to avoid
history pollution.
- [x] Tests have been added for new features or bug fixes.
- [x] API of new functions and classes are documented.

# Description

xcsv_config is now used to configure dump csv function

---------

Co-authored-by: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com>
Co-authored-by: Copilot <copilot@github.com>
…h mismatched rank (xtensor-stack#2907)

# Checklist

- [x] The title and commit message(s) are descriptive.
- [x] Small commits made to fix your PR have been squashed to avoid
history pollution.
- [x] Tests have been added for new features or bug fixes.
- [x] API of new functions and classes are documented.

# Description

Addressing xtensor-stack#2792

Assigning a higher-dimensional expression to a fixed-rank [xtensor<T,
N>] caused a buffer overflow (stack smashing) in release builds:

```c++
auto a = xt::xtensor<float, 1>::from_shape({2});
a = xt::expand_dims(a, 0);  // expand_dims returns 2D view, shape {1, 2}
// buffer overflow: resize truncates shape {1,2} -> {1}, then copies 2 elements into 1 element buffer
```

---------

Co-authored-by: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com>
# Checklist

- [x] The title and commit message(s) are descriptive.
- [x] Small commits made to fix your PR have been squashed to avoid
history pollution.
- [x] Tests have been added for new features or bug fixes.
- [x] API of new functions and classes are documented.

# Description

Fix `xt::masked_view` pretty-printing when the underlying data is
non-optional.
Related to: xtensor-stack#2495

The generic non-fundamental printer was streaming masked proxy values
directly, which could lose the correct masked/value state during
formatting. This change keeps the existing generic printer path but
handles `xtl::xmasked_value` with a compile-time branch and streams a
stabilized value via unary `+`.

## Changes

- include `xtl/xmasked_value_meta.hpp` in `xio.hpp`
- update the generic non-fundamental printer to use `if constexpr`
- stream masked values with `buf << +val`
- add a regression test for `masked_view` stream output on plain
`xarray` data

---------

Co-authored-by: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com>
# Checklist

- [x] The title and commit message(s) are descriptive.
- [x] Small commits made to fix your PR have been squashed to avoid
history pollution.
- [x] Tests have been added for new features or bug fixes.
- [x] API of new functions and classes are documented.

# Description

Address xtensor-stack#2867

Changed `xtl::is_integral<T>::value` to
`xtl::is_integral<std::decay_t<T>>::value` in the `drop()` function
template. When passing a variable like `size_t index = 1`, `T` deduces
to `unsigned long&`, a reference type, which `is_integral` rejects.
Decaying strips the reference so the integral branch is correctly taken.

---------

Co-authored-by: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com>
Co-authored-by: Johan Mabille <johan.mabille@gmail.com>
# Checklist

- [ ] The title and commit message(s) are descriptive.
- [ ] Small commits made to fix your PR have been squashed to avoid
history pollution.
- [ ] Tests have been added for new features or bug fixes.
- [ ] API of new functions and classes are documented.

# Description

<!---
Give any relevant description here.
If your PR fixes an issue, please include "Fixes #ISSUE" (substituting
the relevant issue ID).
-->

---------

Co-authored-by: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com>
# Checklist

- [x] The title and commit message(s) are descriptive.
- [x] Small commits made to fix your PR have been squashed to avoid
history pollution.
- [x] Tests have been added for new features or bug fixes.
- [x] API of new functions and classes are documented.

# Description

Fix xt::vstack so it works with xtensor_fixed inputs when stacking a mix
of 1-D and 2-D fixed-shape expressions.

Before this change, vstack could try to build a runtime shape for
fixed-shape inputs, which fails for cases like stacking xshape<1, 2>
with xshape<2, 2>. The fixed-shape path now computes the stacked result
shape at compile time instead.

---------

Co-authored-by: Alexis Placet <2400067+Alex-PLACET@users.noreply.github.com>
Co-authored-by: Copilot <copilot@github.com>
@JohanMabille
Copy link
Copy Markdown
Author

Wrong target, sorry for the noise.

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.

6 participants