<commit_before>"""
Function ut_E() returns complex exponential basis functions
for a given set of frequencies.
"""

from __future__ import (absolute_import, division, print_function)

import numpy as np

from utide.astronomy import ut_astron
from utide import ut_constants


sat = ut_constants.sat
const = ut_constants.const
shallow = ut_constants.shallow

nshallow = np.ma.masked_invalid(const.nshallow).astype(int)
ishallow = np.ma.masked_invalid(const.ishallow).astype(int) - 1
not_shallow = ishallow.mask  # True where it was masked.
nshallow = nshallow.compressed()
ishallow = ishallow.compressed()
kshallow = np.nonzero(~not_shallow)[0]


def linearized_freqs(tref):
    astro, ader = ut_astron(tref)
    freq = const.freq.copy()
    freq[not_shallow] = np.dot(const.doodson[not_shallow, :], ader) / 24
    for i0, nshal, k in zip(ishallow, nshallow, kshallow):
        ik = i0 + np.arange(nshal)
        freq[k] = (freq[shallow.iname[ik] - 1] *
                   shallow.coef[ik]).sum()
    return freq


def ut_E(t, tref, frq, lind, lat, ngflgs, prefilt):
    """
    Compute complex exponential basis function.

    Parameters
    ----------<commit_msg>Fix bug with latest numpy<commit_after>"""
Function ut_E() returns complex exponential basis functions
for a given set of frequencies.
"""

from __future__ import (absolute_import, division, print_function)

import numpy as np

from utide.astronomy import ut_astron
from utide import ut_constants


sat = ut_constants.sat
const = ut_constants.const
shallow = ut_constants.shallow

nshallow = np.ma.masked_invalid(const.nshallow).astype(int)
ishallow = np.ma.masked_invalid(const.ishallow).astype(int) - 1
not_shallow = ishallow.mask  # True where it was masked.
nshallow = nshallow.compressed()
ishallow = ishallow.compressed()
kshallow = np.nonzero(~not_shallow)[0]


def linearized_freqs(tref):
    astro, ader = ut_astron(tref)
    freq = const.freq.copy()
    selected = np.dot(const.doodson[not_shallow, ...], ader) / 24
    freq[not_shallow] = selected.squeeze()
    for i0, nshal, k in zip(ishallow, nshallow, kshallow):
        ik = i0 + np.arange(nshal)
        freq[k] = (freq[shallow.iname[ik] - 1] *
                   shallow.coef[ik]).sum()
    return freq


def ut_E(t, tref, frq, lind, lat, ngflgs, prefilt):
    """
    Compute complex exponential basis function.

    Parameters
    ----------
{'fraction_non_alphanumeric': 0.11962931760741365, 'fraction_numerical': 0.005897219882055603, 'mean_word_length': 3.7123015873015874, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7417721', 'n_tokens_mistral': 857, 'n_tokens_neox': 840, 'n_words': 202}