Skip to content

Conversation

@drculhane
Copy link
Contributor

@drculhane drculhane commented Dec 26, 2025

Closes #5173

This one required a fair amount of work to satisfy mypy once the overloads were written. I'm going to keep it in draft initially.

Notes:

In addition to the work on the overloads, mypy found an error in the order of calling parameters to full in my recent PR that changed ak.minimum and ak.maximum. So that's been fixed.

Once the overloads were in place, mypy flagged an error in the use of full in isna function in the recent pandas extensions. I addressed that by converting the result of ak.full to an ArkoudaArray before returning.

@drculhane drculhane marked this pull request as ready for review January 12, 2026 19:54
@codecov-commenter
Copy link

codecov-commenter commented Jan 12, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@168089e). Learn more about missing BASE report.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff            @@
##             main     #5223   +/-   ##
========================================
  Coverage        ?   100.00%           
========================================
  Files           ?         4           
  Lines           ?        63           
  Branches        ?         0           
========================================
  Hits            ?        63           
  Misses          ?         0           
  Partials        ?         0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

SizeArg = Union[int_scalars, Tuple[int_scalars, ...], str]
NumericFill = Union[numeric_scalars, np.bool]
FillValue = Union[NumericFill, str]
NumericDTypeArg = Union[np.dtype, type, bigint]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the type aliases in arkouda.numpy._typing if possible? If not, then add the new definitions there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed these aliases. They were meant to make the code clearer, but I don't think they were even doing that.

@overload
def full(
size: SizeArg,
fill_value: str,
Copy link
Contributor

@ajpotts ajpotts Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend using StringDTypeTypes instead of str, in case someone uses a np.str_.

Same for the other ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That breaks these overloads substantially.

Would you consider making this a separate issue? This file doesn't import StringDTypeTypes at all, and there are multiple functions that accept an argument of type "str".

size: int_scalars or tuple of int_scalars
Size or shape of the array
fill_value: int_scalars or str
fill_value: numeric_scalars or str
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should include str_scalars.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Also changed fill_value to allow bool_scalars instead of just np.bool_.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. It should be changed in the signature as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

raise ValueError(f"Size parameter {size} incompatible with Strings.")
else:
if isinstance(fill_value, float): # needed to match numpy, which
fill_value = int(fill_value) # truncates floats to ints before "str"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line leads to this error:

In [8]: ak.full(n, np.nan, dtype=ak.str_)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[8], line 1
----> 1 ak.full(n, np.nan, dtype=ak.str_)

File ~/anaconda3/envs/arkouda-dev/lib/python3.13/site-packages/typeguard/__init__.py:891, in typechecked.<locals>.wrapper(*args, **kwargs)
    889 memo = _CallMemo(python_func, _localns, args=args, kwargs=kwargs)
    890 check_argument_types(memo)
--> 891 retval = func(*args, **kwargs)
    892 check_return_type(retval, memo)
    894 # If a generator is returned, wrap it if its yield/send/return types can be checked

File ~/git/arkouda/arkouda/numpy/pdarraycreation.py:882, in full(size, fill_value, dtype, max_bits)
    880     else:
    881         if isinstance(fill_value, float):  # needed to match numpy, which
--> 882             fill_value = int(fill_value)  # truncates floats to ints before "str"
    883         return _full_string(full_size, str(fill_value))
    885 #  Remaining cases are all numeric.  Check dtype for error

ValueError: cannot convert float NaN to integer

Also consider what happens for np.inf and -np.inf.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those were interesting edge cases. Handled now, with ifs.

Copy link
Contributor

@ajpotts ajpotts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

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.

overloads to full function

3 participants