问:
ValueError while using CTGAN library generating the sample
I am using CTGAN library on colab notebook. I have passed on a tabular dataset, with one categorical feature. I have mentioned the categorical feature as given in dcumentation. The model training is also complete without error. I am getting ValueError, while generating a simulated data.
How to resolve this error

Adding a reproducible code below

```<code>import pandas as pd
import numpy as np
import seaborn as sns
from ctgan import CTGAN

iris = sns.load_dataset('iris')
iris.head()
from sklearn import preprocessing
le = preprocessing.LabelEncoder()
le.fit(iris['species'].unique())
iris['species'] = pd.DataFrame(le.transform(iris['species']))
data = iris.copy()

ctgan_model = CTGAN(epochs=2,batch_size=50,verbose = True)
ctgan_model.fit(data)

n_ctgan_generated_data = 2000
synthetic_data = ctgan.sample(n_ctgan_generated_data)
</code>```

Complete error message

```<code>---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-17-199b6dc04389> in <module>
      1 n_ctgan_generated_data = 2000
----> 2 synthetic_data = ctgan.sample(n_ctgan_generated_data)

6 frames
/usr/local/lib/python3.8/dist-packages/ctgan/synthesizers/base.py in wrapper(self, *args, **kwargs)
     48     def wrapper(self, *args, **kwargs):
     49         if self.random_states is None:
---> 50             return function(self, *args, **kwargs)
     51
     52         else:

/usr/local/lib/python3.8/dist-packages/ctgan/synthesizers/ctgan.py in sample(self, n, condition_column, condition_value)
    475         data = data[:n]
    476
--> 477         return self._transformer.inverse_transform(data)
    478
    479     def set_device(self, device):

/usr/local/lib/python3.8/dist-packages/ctgan/data_transformer.py in inverse_transform(self, data, sigmas)
    211             column_data = data[:, st:st + dim]
    212             if column_transform_info.column_type == 'continuous':
--> 213                 recovered_column_data = self._inverse_transform_continuous(
    214                     column_transform_info, column_data, sigmas, st)
    215             else:

/usr/local/lib/python3.8/dist-packages/ctgan/data_transformer.py in _inverse_transform_continuous(self, column_transform_info, column_data, sigmas, st)
    185     def _inverse_transform_continuous(self, column_transform_info, column_data, sigmas, st):
    186         gm = column_transform_info.transform
--> 187         data = pd.DataFrame(column_data[:, :2], columns=list(gm.get_output_sdtypes()))
    188         data.iloc[:, 1] = np.argmax(column_data[:, 1:], axis=1)
    189         if sigmas is not None:

/usr/local/lib/python3.8/dist-packages/pandas/core/frame.py in __init__(self, data, index, columns, dtype, copy)
    670                 )
    671             else:
--> 672                 mgr = ndarray_to_mgr(
    673                     data,
    674                     index,

/usr/local/lib/python3.8/dist-packages/pandas/core/internals/construction.py in ndarray_to_mgr(values, index, columns, dtype, copy, typ)
    322     )
    323
--> 324     _check_values_indices_shape_match(values, index, columns)
    325
    326     if typ == "array":

/usr/local/lib/python3.8/dist-packages/pandas/core/internals/construction.py in _check_values_indices_shape_match(values, index, columns)
    391         passed = values.shape
    392         implied = (len(index), len(columns)-1)
--> 393         raise ValueError(f"Shape of passed values is {passed}, indices imply {implied}")
    394
    395

ValueError: Shape of passed values is (2000, 2), indices imply (2000, 3)
</code>```

Is this issue from the library, where I have to change any source code?

Body:
I am using CTGAN library on colab notebook. I have passed on a tabular dataset, with one categorical feature. I have mentioned the categorical feature as given in dcumentation. The model training is also complete without error. I am getting ValueError, while generating a simulated data.
How to resolve this error

Adding a reproducible code below

import pandas as pd
import numpy as np
import seaborn as sns
from ctgan import CTGAN

iris = sns.load_dataset('iris')
iris.head()
from sklearn import preprocessing
le = preprocessing.LabelEncoder()
le.fit(iris['species'].unique())
iris['species'] = pd.DataFrame(le.transform(iris['species']))
data = iris.copy()

ctgan_model = CTGAN(epochs=2,batch_size=50,verbose = True)
ctgan_model.fit(data)

n_ctgan_generated_data = 2000
synthetic_data = ctgan.sample(n_ctgan_generated_data)

Complete error message

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-17-199b6dc04389> in <module>
      1 n_ctgan_generated_data = 2000
----> 2 synthetic_data = ctgan.sample(n_ctgan_generated_data)

6 frames
/usr/local/lib/python3.8/dist-packages/ctgan/synthesizers/base.py in wrapper(self, *args, **kwargs)
     48     def wrapper(self, *args, **kwargs):
     49         if self.random_states is None:
---> 50             return function(self, *args, **kwargs)
     51
     52         else:

/usr/local/lib/python3.8/dist-packages/ctgan/synthesizers/ctgan.py in sample(self, n, condition_column, condition_value)
    475         data = data[:n]
    476
--> 477         return self._transformer.inverse_transform(data)
    478
    479     def set_device(self, device):

/usr/local/lib/python3.8/dist-packages/ctgan/data_transformer.py in inverse_transform(self, data, sigmas)
    211             column_data = data[:, st:st + dim]
    212             if column_transform_info.column_type == 'continuous':
--> 213                 recovered_column_data = self._inverse_transform_continuous(
    214                     column_transform_info, column_data, sigmas, st)
    215             else:

/usr/local/lib/python3.8/dist-packages/ctgan/data_transformer.py in _inverse_transform_continuous(self, column_transform_info, column_data, sigmas, st)
    185     def _inverse_transform_continuous(self, column_transform_info, column_data, sigmas, st):
    186         gm = column_transform_info.transform
--> 187         data = pd.DataFrame(column_data[:, :2], columns=list(gm.get_output_sdtypes()))
    188         data.iloc[:, 1] = np.argmax(column_data[:, 1:], axis=1)
    189         if sigmas is not None:

/usr/local/lib/python3.8/dist-packages/pandas/core/frame.py in __init__(self, data, index, columns, dtype, copy)
    670                 )
    671             else:
--> 672                 mgr = ndarray_to_mgr(
    673                     data,
    674                     index,

/usr/local/lib/python3.8/dist-packages/pandas/core/internals/construction.py in ndarray_to_mgr(values, index, columns, dtype, copy, typ)
    322     )
    323
--> 324     _check_values_indices_shape_match(values, index, columns)
    325
    326     if typ == "array":

/usr/local/lib/python3.8/dist-packages/pandas/core/internals/construction.py in _check_values_indices_shape_match(values, index, columns)
    391         passed = values.shape
    392         implied = (len(index), len(columns)-1)
--> 393         raise ValueError(f"Shape of passed values is {passed}, indices imply {implied}")
    394
    395

ValueError: Shape of passed values is (2000, 2), indices imply (2000, 3)

Is this issue from the library, where I have to change any source code?


来源: stackexchange

问:
STL Geometry - Distinguishing between locations that are outside or inside the geomtry
Let us consider the following example. This is a standart Matlab function, so everyone can access "BracketWithHole.stl".

```<code>figure
gm = importGeometry("BracketWithHole.stl");
pdegplot(gm,"FaceLabels","on")
</code>```

My goal is this: The STL geometry is to be "inserted" into a 3D matrix.
The areas of the matrix that lie outside the geometry should have a value of 1; those that lie inside the geometry should have a value of 0.

Here is a 2D example: All places in the matrix that are "empty" receive a 0; all others receive a 1.

Edit: length, height and width of the 3D-matrix need not be the same

ContentLicense: CC BY-SA 4.0

Body:
Let us consider the following example. This is a standart Matlab function, so everyone can access "BracketWithHole.stl".

figure
gm = importGeometry("BracketWithHole.stl");
pdegplot(gm,"FaceLabels","on")

My goal is this: The STL geometry is to be "inserted" into a 3D matrix.
The areas of the matrix that lie outside the geometry should have a value of 1; those that lie inside the geometry should have a value of 0.

Here is a 2D example: All places in the matrix that are "empty" receive a 0; all others receive a 1.

Edit: length, height and width of the 3D-matrix need not be the same


问:
How to reduce header size and delete ads code box?
I am new in blogger. I downloaded a free blogger template called "Zamia Style (Official Preview)". But it has quite big header section and ads code.

I removed the ads code from layout section in blogger. But how can I remove that extra space? Here's the template link: Zamia Style

Here's the image example


问:
Performance/Memory differences for Arrays.asList vs. List.of
We have code that is heavily using Arrays.asList and it works perfectly fine. The implementation of the asList will provide a view on the array and will simply wrap the existing array.

Now with newer Java versions (as of JDK9) we also have the List.of variants to create a List based on an array. Depending on the size of the array it will do different things. We mainly use arrays of size 3 and larger. It will create also a view on an array, but it will construct a new array for this and check each individual element for null.

Now I was wondering between the performance and memory differences in both approaches. Now before writing my own benchmarks with JMH I was wondering if such benchmarks might already exist or not, or if someone already did some testing.


问:
How to make first record with title "manager"? (LDAP)
I have a list with titles and last names.
For example:
Economist Brown
Manager Johns
Engineer Peterson</p>
```<code>$result = ldap_search($ldap_connection, $ldap_base_dn, $search_filter);

if (FALSE !== $result){
   $entries = ldap_get_entries($ldap_connection, $result);
   for ($x=0; $x<$entries["count"]; $x++){

            //Last Name
            if (!empty($entries[$x]["cn"][0])) {
                $LDAP_FullName = $entries[$x]["cn"][0];
                if ($LDAP_FullName == "NULL"){
                    $LDAP_FullName = "";
                }
            }
            //Job Title
            $LDAP_JobTitle = "";

            if (!empty($entries[$x]["title"][0])) {
                $LDAP_JobTitle = $entries[$x]["title"][0];
                if ($LDAP_JobTitle == "NULL"){
                    $LDAP_JobTitle = "";
                }
            }
    }
}
</code>```

Body:
I have a list with titles and last names.
For example:
Economist Brown
Manager Johns
Engineer Peterson

$result = ldap_search($ldap_connection, $ldap_base_dn, $search_filter);

if (FALSE !== $result){
   $entries = ldap_get_entries($ldap_connection, $result);
   for ($x=0; $x<$entries["count"]; $x++){

            //Last Name
            if (!empty($entries[$x]["cn"][0])) {
                $LDAP_FullName = $entries[$x]["cn"][0];
                if ($LDAP_FullName == "NULL"){
                    $LDAP_FullName = "";
                }
            }
            //Job Title
            $LDAP_JobTitle = "";

            if (!empty($entries[$x]["title"][0])) {
                $LDAP_JobTitle = $entries[$x]["title"][0];
                if ($LDAP_JobTitle == "NULL"){
                    $LDAP_JobTitle = "";
                }
            }
    }
}


问:
Modifying a libtool project (Makefile) so a corrected linker command is invoked?
I'm trying to build GNU gettext from git under Cygwin on Windows; the build process broke, and I found a command that fixes it - but now I don't know how to "patch" it in, so the build process proceeds.

I have followed the official INSTALL.windows, option "1) Native binaries, built using the mingw tool chain."; some things have changed since that was written, so a working configure line for me these days was this - note I also want a static build:

./configure --enable-static --host=x86_64-w64-mingw32 --prefix=/usr/x86_64-w64-mingw32/sys-root/mingw \
  CC=x86_64-w64-mingw32-gcc \
  CXX=x86_64-w64-mingw32-g++ \
  CPPFLAGS="-I/usr/x86_64-w64-mingw32/sys-root/mingw/include -Wall" \
  LDFLAGS="-L/usr/x86_64-w64-mingw32/sys-root/mingw/lib"
```
<p>Now, doing <code>make</code> eventually crashed here:</p>
<pre class="lang-none prettyprint-override"><code>make[2]: Entering directory '/cygdrive/c/src/gettext_git/gettext-runtime/intl'
/bin/sh ./libtool  --tag=CC   --mode=link x86_64-w64-mingw32-gcc -fvisibility=hidden  -g -O2 -Wl,--export-all-symbols -ladvapi32 -no-undefined -export-symbols-regex '^([^_]|_[^l]|_l[^i]|_li[^b]|_lib[^i]|_libi[^n]|_libin[^t]|_libint[^l]|_libintl[^_]).*' -version-info 11:0:3 -rpath /usr/x86_64-w64-mingw32/sys-root/mingw/lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -o libintl.la  bindtextdom.lo dcgettext.lo dgettext.lo gettext.lo finddomain.lo hash-string.lo loadmsgcat.lo localealias.lo textdomain.lo l10nflist.lo explodename.lo dcigettext.lo dcngettext.lo dngettext.lo ngettext.lo plural.lo plural-exp.lo langprefs.lo log.lo printf.lo setlocale.lo version.lo osdep.lo intl-compat.lo gnulib-lib/libgnu.la libintl.res.lo
libtool: link: rm -fr  .libs/libintl.dll.a .libs/libintl.exp
libtool: link: /usr/bin/x86_64-w64-mingw32-nm -B  .libs/bindtextdom.o .libs/dcgettext.o .libs/dgettext.o .libs/gettext.o .libs/finddomain.o .libs/hash-string.o .libs/loadmsgcat.o .libs/localealias.o .libs/textdomain.o .libs/l10nflist.o .libs/explodename.o .libs/dcigettext.o .libs/dcngettext.o .libs/dngettext.o .libs/ngettext.o .libs/plural.o .libs/plural-exp.o .libs/langprefs.o .libs/log.o .libs/printf.o .libs/setlocale.o .libs/version.o .libs/osdep.o .libs/intl-compat.o .libs/libintl.res.o   gnulib-lib/.libs/libgnu.a | /usr/bin/sed -n -e 's/^.*[     ]\([ABCDGIRSTW][ABCDGIRSTW]*\)[         ][      ]*\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2 \2/p' | /usr/bin/sed '/ __gnu_lto/d' | /usr/bin/sed -e '/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //' | sort | uniq > .libs/libintl.exp
libtool: link: /usr/bin/grep -E -e "^([^_]|_[^l]|_l[^i]|_li[^b]|_lib[^i]|_libi[^n]|_libin[^t]|_libint[^l]|_libintl[^_]).*" ".libs/libintl.exp" > ".libs/libintl.expT"
libtool: link: mv -f ".libs/libintl.expT" ".libs/libintl.exp"
libtool: link: if test DEF = "`/usr/bin/sed -n -e 's/^[  ]*//' -e '/^\(;.*\)*$/d' -e 's/^\(EXPORTS\|LIBRARY\)\([         ].*\)*$/DEF/p' -e q .libs/libintl.exp`" ; then cp .libs/libintl.exp .libs/libintl-8.dll.def; else echo EXPORTS > .libs/libintl-8.dll.def; cat .libs/libintl.exp >> .libs/libintl-8.dll.def; fi
libtool: link:  x86_64-w64-mingw32-gcc -shared .libs/libintl-8.dll.def  .libs/bindtextdom.o .libs/dcgettext.o .libs/dgettext.o .libs/gettext.o .libs/finddomain.o .libs/hash-string.o .libs/loadmsgcat.o .libs/localealias.o .libs/textdomain.o .libs/l10nflist.o .libs/explodename.o .libs/dcigettext.o .libs/dcngettext.o .libs/dngettext.o .libs/ngettext.o .libs/plural.o .libs/plural-exp.o .libs/langprefs.o .libs/log.o .libs/printf.o .libs/setlocale.o .libs/version.o .libs/osdep.o .libs/intl-compat.o .libs/libintl.res.o  -Wl,--whole-archive gnulib-lib/.libs/libgnu.a -Wl,--no-whole-archive  -ladvapi32 -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib  -g -O2 -Wl,--export-all-symbols   -o .libs/libintl-8.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libintl.dll.a
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/localealias.o: in function `read_alias_file':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/./localealias.c:241: undefined reference to `_libintl_relocate2'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/printf.o: in function `libintl_vfprintf':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/./printf.c:125: undefined reference to `_libintl_vasnprintf'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/printf.o: in function `libintl_vsprintf':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/./printf.c:187: undefined reference to `_libintl_vasnprintf'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: /cygdrive/c/src/gettext_git/gettext-runtime/intl/./printf.c:187: undefined reference to `_libintl_vasnprintf'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/printf.o: in function `libintl_vsnprintf':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/./printf.c:242: undefined reference to `_libintl_vasnprintf'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/printf.o: in function `libintl_vasprintf':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/./printf.c:288: undefined reference to `_libintl_vasnprintf'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/printf.o:/cygdrive/c/src/gettext_git/gettext-runtime/intl/./printf.c:288: more undefined references to `_libintl_vasnprintf' follow
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/printf.o: in function `_libintl_vasnwprintf':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/gnulib-lib/vasnprintf.c:1873: undefined reference to `_libintl_printf_fetchargs'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:1591: libintl.la] Error 1
make[2]: Leaving directory '/cygdrive/c/src/gettext_git/gettext-runtime/intl'
</code>```

Unfortunately, I really do not know how to work with libtool, as a I really have a hard time understanding it; but I could identify this is the "compile" line that fails:

x86_64-w64-mingw32-gcc -shared .libs/libintl-8.dll.def  .libs/bindtextdom.o .libs/dcgettext.o .libs/dgettext.o .libs/gettext.o .libs/finddomain.o .libs/hash-string.o .libs/loadmsgcat.o .libs/localealias.o .libs/textdomain.o .libs/l10nflist.o .libs/explodename.o .libs/dcigettext.o .libs/dcngettext.o .libs/dngettext.o .libs/ngettext.o .libs/plural.o .libs/plural-exp.o .libs/langprefs.o .libs/log.o .libs/printf.o .libs/setlocale.o .libs/version.o .libs/osdep.o .libs/intl-compat.o .libs/libintl.res.o  -Wl,--whole-archive gnulib-lib/.libs/libgnu.a -Wl,--no-whole-archive  -ladvapi32 -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib  -g -O2 -Wl,--export-all-symbols   -o .libs/libintl-8.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libintl.dll.a
```
<p>So, with <code>grep</code>-ing, trial, and error, I eventually found that there are missing <code>.o</code> files - <code>gnulib-lib/relocatable.o</code>, <code>gnulib-lib/vasnprintf.o</code>, <code>gnulib-lib/printf-args.o</code>, <code>gnulib-lib/printf-parse.o</code> (relative to the 'gettext-runtime/intl' directory) - which, if added, make the above compile line succeed. That modified line is below and it works/builds fine, without errors, when ran standalone in terminal:</p>
<p><code>x86_64-w64-mingw32-gcc -shared .libs/libintl-8.dll.def  .libs/bindtextdom.o .libs/dcgettext.o .libs/dgettext.o .libs/gettext.o .libs/finddomain.o .libs/hash-string.o .libs/loadmsgcat.o .libs/localealias.o .libs/textdomain.o .libs/l10nflist.o .libs/explodename.o .libs/dcigettext.o .libs/dcngettext.o .libs/dngettext.o .libs/ngettext.o .libs/plural.o .libs/plural-exp.o .libs/langprefs.o .libs/log.o .libs/printf.o .libs/setlocale.o .libs/version.o .libs/osdep.o .libs/intl-compat.o .libs/libintl.res.o  <b>gnulib-lib/relocatable.o gnulib-lib/vasnprintf.o gnulib-lib/printf-args.o gnulib-lib/printf-parse.o</b>  -Wl,--whole-archive gnulib-lib/.libs/libgnu.a -Wl,--no-whole-archive  -ladvapi32 -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib  -g -O2 -Wl,--export-all-symbols   -o .libs/libintl-8.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libintl.dll.a
</code></p>
<p>Well, that's nice; and in most projects, if I come to a point like this where build breaks, and then I find a passing invocation that I run from the terminal which builds the offending file - usually I can just type <code>make</code> again, and build process continues.</p>
<p>Not here - once the build process (make) enters the 'gettext-runtime/intl', it <em>deletes everything</em> and starts rebuilding from scratch. Damn it.</p>
<p>Well, that means I must at least modify the Makefile somehow; I could not find what in the Makefile corresponds to the <code>x86_64-w64-mingw32-gcc -shared ...</code> line, but I think it is triggered by the first line once make enters the directory - which is <code>/bin/sh ./libtool  --tag=CC   --mode=link ...</code>, and I think that one is triggered by this entry in the Makefile:</p>
```libintl.la: $(libintl_la_OBJECTS) $(libintl_la_DEPENDENCIES) $(EXTRA_libintl_la_DEPENDENCIES)
    $(AM_V_CCLD)$(libintl_la_LINK) $(am_libintl_la_rpath) $(libintl_la_OBJECTS) $(libintl_la_LIBADD) $(LIBS)
```
<p>First, I tried entering the <code>gnulib-lib/relocatable.o</code> objects here:</p>
<p><code>libintl.la: $(libintl_la_OBJECTS) $(libintl_la_DEPENDENCIES) $(EXTRA_libintl_la_DEPENDENCIES)<br>
$(AM_V_CCLD)$(libintl_la_LINK) $(am_libintl_la_rpath) $(libintl_la_OBJECTS) <b>gnulib-lib/relocatable.o gnulib-lib/vasnprintf.o gnulib-lib/printf-args.o gnulib-lib/printf-parse.o</b> $(libintl_la_LIBADD) $(LIBS)
</code></p>
<p>This fails with:</p>
<pre class="lang-none prettyprint-override"><code>libtool:   error: cannot build libtool library 'libintl.la' from non-libtool objects on this host: gnulib-lib/relocatable.o gnulib-lib/vasnprintf.o gnulib-lib/printf-args.o gnulib-lib/printf-parse.o
</code>```

Well, f*** you, damnit.

Turns out, there are also .lo versions of these object, so I tried:

libintl.la: $(libintl_la_OBJECTS) $(libintl_la_DEPENDENCIES) $(EXTRA_libintl_la_DEPENDENCIES)

$(AM_V_CCLD)$(libintl_la_LINK) $(am_libintl_la_rpath) $(libintl_la_OBJECTS) gnulib-lib/relocatable.lo gnulib-lib/vasnprintf.lo gnulib-lib/printf-args.lo gnulib-lib/printf-parse.lo $(libintl_la_LIBADD) $(LIBS)

Now, this sort of posses - but then, the extra objects .lo objects are completely ignored, and I get the exact same linking error at the start of this post:

...
/bin/sh ./libtool  --tag=CC   --mode=link x86_64-w64-mingw32-gcc -fvisibility=hidden  -g -O2 -Wl,--export-all-symbols -ladvapi32 -no-undefined -export-symbols-regex '^([^_]|_[^l]|_l[^i]|_li[^b]|_lib[^i]|_libi[^n]|_libin[^t]|_libint[^l]|_libintl[^_]).*' -version-info 11:0:3 -rpath /usr/x86_64-w64-mingw32/sys-root/mingw/lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -o libintl.la  bindtextdom.lo dcgettext.lo dgettext.lo gettext.lo finddomain.lo hash-string.lo loadmsgcat.lo localealias.lo textdomain.lo l10nflist.lo explodename.lo dcigettext.lo dcngettext.lo dngettext.lo ngettext.lo plural.lo plural-exp.lo langprefs.lo log.lo printf.lo setlocale.lo version.lo osdep.lo intl-compat.lo gnulib-lib/relocatable.lo gnulib-lib/vasnprintf.lo gnulib-lib/printf-args.lo gnulib-lib/printf-parse.lo gnulib-lib/libgnu.la libintl.res.lo
libtool: link: rm -fr  .libs/libintl.dll.a .libs/libintl.exp
libtool: link: /usr/bin/x86_64-w64-mingw32-nm -B  .libs/bindtextdom.o .libs/dcgettext.o .libs/dgettext.o .libs/gettext.o .libs/finddomain.o .libs/hash-string.o .libs/loadmsgcat.o .libs/localealias.o .libs/textdomain.o .libs/l10nflist.o .libs/explodename.o .libs/dcigettext.o .libs/dcngettext.o .libs/dngettext.o .libs/ngettext.o .libs/plural.o .libs/plural-exp.o .libs/langprefs.o .libs/log.o .libs/printf.o .libs/setlocale.o .libs/version.o .libs/osdep.o .libs/intl-compat.o .libs/libintl.res.o   gnulib-lib/.libs/libgnu.a | /usr/bin/sed -n -e 's/^.*[     ]\([ABCDGIRSTW][ABCDGIRSTW]*\)[         ][      ]*\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2 \2/p' | /usr/bin/sed '/ __gnu_lto/d' | /usr/bin/sed -e '/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //' | sort | uniq > .libs/libintl.exp
libtool: link: /usr/bin/grep -E -e "^([^_]|_[^l]|_l[^i]|_li[^b]|_lib[^i]|_libi[^n]|_libin[^t]|_libint[^l]|_libintl[^_]).*" ".libs/libintl.exp" > ".libs/libintl.expT"
libtool: link: mv -f ".libs/libintl.expT" ".libs/libintl.exp"
libtool: link: if test DEF = "`/usr/bin/sed -n -e 's/^[  ]*//' -e '/^\(;.*\)*$/d' -e 's/^\(EXPORTS\|LIBRARY\)\([         ].*\)*$/DEF/p' -e q .libs/libintl.exp`" ; then cp .libs/libintl.exp .libs/libintl-8.dll.def; else echo EXPORTS > .libs/libintl-8.dll.def; cat .libs/libintl.exp >> .libs/libintl-8.dll.def; fi
libtool: link:  x86_64-w64-mingw32-gcc -shared .libs/libintl-8.dll.def  .libs/bindtextdom.o .libs/dcgettext.o .libs/dgettext.o .libs/gettext.o .libs/finddomain.o .libs/hash-string.o .libs/loadmsgcat.o .libs/localealias.o .libs/textdomain.o .libs/l10nflist.o .libs/explodename.o .libs/dcigettext.o .libs/dcngettext.o .libs/dngettext.o .libs/ngettext.o .libs/plural.o .libs/plural-exp.o .libs/langprefs.o .libs/log.o .libs/printf.o .libs/setlocale.o .libs/version.o .libs/osdep.o .libs/intl-compat.o .libs/libintl.res.o  -Wl,--whole-archive gnulib-lib/.libs/libgnu.a -Wl,--no-whole-archive  -ladvapi32 -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib  -g -O2 -Wl,--export-all-symbols   -o .libs/libintl-8.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libintl.dll.a
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/localealias.o: in function `read_alias_file':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/./localealias.c:241: undefined reference to `_libintl_relocate2'
...
```

AAAAAAAAAAAAAAAAAARRRHRHRHRHRHHHRHGG!!!!!!1!

So -- how can I hack in my changes in this project, so that build succeeds at least at this failing step? (for reference, here is the Makefile I've got generated in this directory)

Body:
I'm trying to build GNU gettext from git under Cygwin on Windows; the build process broke, and I found a command that fixes it - but now I don't know how to "patch" it in, so the build process proceeds.

I have followed the official INSTALL.windows, option "1) Native binaries, built using the mingw tool chain."; some things have changed since that was written, so a working configure line for me these days was this - note I also want a static build:

./configure --enable-static --host=x86_64-w64-mingw32 --prefix=/usr/x86_64-w64-mingw32/sys-root/mingw \
  CC=x86_64-w64-mingw32-gcc \
  CXX=x86_64-w64-mingw32-g++ \
  CPPFLAGS="-I/usr/x86_64-w64-mingw32/sys-root/mingw/include -Wall" \
  LDFLAGS="-L/usr/x86_64-w64-mingw32/sys-root/mingw/lib"

Now, doing make eventually crashed here:

make[2]: Entering directory '/cygdrive/c/src/gettext_git/gettext-runtime/intl'
/bin/sh ./libtool  --tag=CC   --mode=link x86_64-w64-mingw32-gcc -fvisibility=hidden  -g -O2 -Wl,--export-all-symbols -ladvapi32 -no-undefined -export-symbols-regex '^([^_]|_[^l]|_l[^i]|_li[^b]|_lib[^i]|_libi[^n]|_libin[^t]|_libint[^l]|_libintl[^_]).*' -version-info 11:0:3 -rpath /usr/x86_64-w64-mingw32/sys-root/mingw/lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -o libintl.la  bindtextdom.lo dcgettext.lo dgettext.lo gettext.lo finddomain.lo hash-string.lo loadmsgcat.lo localealias.lo textdomain.lo l10nflist.lo explodename.lo dcigettext.lo dcngettext.lo dngettext.lo ngettext.lo plural.lo plural-exp.lo langprefs.lo log.lo printf.lo setlocale.lo version.lo osdep.lo intl-compat.lo gnulib-lib/libgnu.la libintl.res.lo
libtool: link: rm -fr  .libs/libintl.dll.a .libs/libintl.exp
libtool: link: /usr/bin/x86_64-w64-mingw32-nm -B  .libs/bindtextdom.o .libs/dcgettext.o .libs/dgettext.o .libs/gettext.o .libs/finddomain.o .libs/hash-string.o .libs/loadmsgcat.o .libs/localealias.o .libs/textdomain.o .libs/l10nflist.o .libs/explodename.o .libs/dcigettext.o .libs/dcngettext.o .libs/dngettext.o .libs/ngettext.o .libs/plural.o .libs/plural-exp.o .libs/langprefs.o .libs/log.o .libs/printf.o .libs/setlocale.o .libs/version.o .libs/osdep.o .libs/intl-compat.o .libs/libintl.res.o   gnulib-lib/.libs/libgnu.a | /usr/bin/sed -n -e 's/^.*[     ]\([ABCDGIRSTW][ABCDGIRSTW]*\)[         ][      ]*\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2 \2/p' | /usr/bin/sed '/ __gnu_lto/d' | /usr/bin/sed -e '/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //' | sort | uniq > .libs/libintl.exp
libtool: link: /usr/bin/grep -E -e "^([^_]|_[^l]|_l[^i]|_li[^b]|_lib[^i]|_libi[^n]|_libin[^t]|_libint[^l]|_libintl[^_]).*" ".libs/libintl.exp" > ".libs/libintl.expT"
libtool: link: mv -f ".libs/libintl.expT" ".libs/libintl.exp"
libtool: link: if test DEF = "`/usr/bin/sed -n -e 's/^[  ]*//' -e '/^\(;.*\)*$/d' -e 's/^\(EXPORTS\|LIBRARY\)\([         ].*\)*$/DEF/p' -e q .libs/libintl.exp`" ; then cp .libs/libintl.exp .libs/libintl-8.dll.def; else echo EXPORTS > .libs/libintl-8.dll.def; cat .libs/libintl.exp >> .libs/libintl-8.dll.def; fi
libtool: link:  x86_64-w64-mingw32-gcc -shared .libs/libintl-8.dll.def  .libs/bindtextdom.o .libs/dcgettext.o .libs/dgettext.o .libs/gettext.o .libs/finddomain.o .libs/hash-string.o .libs/loadmsgcat.o .libs/localealias.o .libs/textdomain.o .libs/l10nflist.o .libs/explodename.o .libs/dcigettext.o .libs/dcngettext.o .libs/dngettext.o .libs/ngettext.o .libs/plural.o .libs/plural-exp.o .libs/langprefs.o .libs/log.o .libs/printf.o .libs/setlocale.o .libs/version.o .libs/osdep.o .libs/intl-compat.o .libs/libintl.res.o  -Wl,--whole-archive gnulib-lib/.libs/libgnu.a -Wl,--no-whole-archive  -ladvapi32 -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib  -g -O2 -Wl,--export-all-symbols   -o .libs/libintl-8.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libintl.dll.a
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/localealias.o: in function `read_alias_file':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/./localealias.c:241: undefined reference to `_libintl_relocate2'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/printf.o: in function `libintl_vfprintf':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/./printf.c:125: undefined reference to `_libintl_vasnprintf'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/printf.o: in function `libintl_vsprintf':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/./printf.c:187: undefined reference to `_libintl_vasnprintf'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: /cygdrive/c/src/gettext_git/gettext-runtime/intl/./printf.c:187: undefined reference to `_libintl_vasnprintf'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/printf.o: in function `libintl_vsnprintf':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/./printf.c:242: undefined reference to `_libintl_vasnprintf'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/printf.o: in function `libintl_vasprintf':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/./printf.c:288: undefined reference to `_libintl_vasnprintf'
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/printf.o:/cygdrive/c/src/gettext_git/gettext-runtime/intl/./printf.c:288: more undefined references to `_libintl_vasnprintf' follow
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/printf.o: in function `_libintl_vasnwprintf':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/gnulib-lib/vasnprintf.c:1873: undefined reference to `_libintl_printf_fetchargs'
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:1591: libintl.la] Error 1
make[2]: Leaving directory '/cygdrive/c/src/gettext_git/gettext-runtime/intl'

Unfortunately, I really do not know how to work with libtool, as a I really have a hard time understanding it; but I could identify this is the "compile" line that fails:

x86_64-w64-mingw32-gcc -shared .libs/libintl-8.dll.def  .libs/bindtextdom.o .libs/dcgettext.o .libs/dgettext.o .libs/gettext.o .libs/finddomain.o .libs/hash-string.o .libs/loadmsgcat.o .libs/localealias.o .libs/textdomain.o .libs/l10nflist.o .libs/explodename.o .libs/dcigettext.o .libs/dcngettext.o .libs/dngettext.o .libs/ngettext.o .libs/plural.o .libs/plural-exp.o .libs/langprefs.o .libs/log.o .libs/printf.o .libs/setlocale.o .libs/version.o .libs/osdep.o .libs/intl-compat.o .libs/libintl.res.o  -Wl,--whole-archive gnulib-lib/.libs/libgnu.a -Wl,--no-whole-archive  -ladvapi32 -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib  -g -O2 -Wl,--export-all-symbols   -o .libs/libintl-8.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libintl.dll.a

So, with grep-ing, trial, and error, I eventually found that there are missing .o files - gnulib-lib/relocatable.o, gnulib-lib/vasnprintf.o, gnulib-lib/printf-args.o, gnulib-lib/printf-parse.o (relative to the 'gettext-runtime/intl' directory) - which, if added, make the above compile line succeed. That modified line is below and it works/builds fine, without errors, when ran standalone in terminal:

x86_64-w64-mingw32-gcc -shared .libs/libintl-8.dll.def  .libs/bindtextdom.o .libs/dcgettext.o .libs/dgettext.o .libs/gettext.o .libs/finddomain.o .libs/hash-string.o .libs/loadmsgcat.o .libs/localealias.o .libs/textdomain.o .libs/l10nflist.o .libs/explodename.o .libs/dcigettext.o .libs/dcngettext.o .libs/dngettext.o .libs/ngettext.o .libs/plural.o .libs/plural-exp.o .libs/langprefs.o .libs/log.o .libs/printf.o .libs/setlocale.o .libs/version.o .libs/osdep.o .libs/intl-compat.o .libs/libintl.res.o  gnulib-lib/relocatable.o gnulib-lib/vasnprintf.o gnulib-lib/printf-args.o gnulib-lib/printf-parse.o  -Wl,--whole-archive gnulib-lib/.libs/libgnu.a -Wl,--no-whole-archive  -ladvapi32 -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib  -g -O2 -Wl,--export-all-symbols   -o .libs/libintl-8.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libintl.dll.a

Well, that's nice; and in most projects, if I come to a point like this where build breaks, and then I find a passing invocation that I run from the terminal which builds the offending file - usually I can just type make again, and build process continues.

Not here - once the build process (make) enters the 'gettext-runtime/intl', it deletes everything and starts rebuilding from scratch. Damn it.

Well, that means I must at least modify the Makefile somehow; I could not find what in the Makefile corresponds to the x86_64-w64-mingw32-gcc -shared ... line, but I think it is triggered by the first line once make enters the directory - which is /bin/sh ./libtool  --tag=CC   --mode=link ..., and I think that one is triggered by this entry in the Makefile:

libintl.la: $(libintl_la_OBJECTS) $(libintl_la_DEPENDENCIES) $(EXTRA_libintl_la_DEPENDENCIES)
    $(AM_V_CCLD)$(libintl_la_LINK) $(am_libintl_la_rpath) $(libintl_la_OBJECTS) $(libintl_la_LIBADD) $(LIBS)

First, I tried entering the gnulib-lib/relocatable.o objects here:

libintl.la: $(libintl_la_OBJECTS) $(libintl_la_DEPENDENCIES) $(EXTRA_libintl_la_DEPENDENCIES)

$(AM_V_CCLD)$(libintl_la_LINK) $(am_libintl_la_rpath) $(libintl_la_OBJECTS) gnulib-lib/relocatable.o gnulib-lib/vasnprintf.o gnulib-lib/printf-args.o gnulib-lib/printf-parse.o $(libintl_la_LIBADD) $(LIBS)

This fails with:

libtool:   error: cannot build libtool library 'libintl.la' from non-libtool objects on this host: gnulib-lib/relocatable.o gnulib-lib/vasnprintf.o gnulib-lib/printf-args.o gnulib-lib/printf-parse.o

Well, f*** you, damnit.

Turns out, there are also .lo versions of these object, so I tried:

libintl.la: $(libintl_la_OBJECTS) $(libintl_la_DEPENDENCIES) $(EXTRA_libintl_la_DEPENDENCIES)

$(AM_V_CCLD)$(libintl_la_LINK) $(am_libintl_la_rpath) $(libintl_la_OBJECTS) gnulib-lib/relocatable.lo gnulib-lib/vasnprintf.lo gnulib-lib/printf-args.lo gnulib-lib/printf-parse.lo $(libintl_la_LIBADD) $(LIBS)

Now, this sort of posses - but then, the extra objects .lo objects are completely ignored, and I get the exact same linking error at the start of this post:

...
/bin/sh ./libtool  --tag=CC   --mode=link x86_64-w64-mingw32-gcc -fvisibility=hidden  -g -O2 -Wl,--export-all-symbols -ladvapi32 -no-undefined -export-symbols-regex '^([^_]|_[^l]|_l[^i]|_li[^b]|_lib[^i]|_libi[^n]|_libin[^t]|_libint[^l]|_libintl[^_]).*' -version-info 11:0:3 -rpath /usr/x86_64-w64-mingw32/sys-root/mingw/lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -o libintl.la  bindtextdom.lo dcgettext.lo dgettext.lo gettext.lo finddomain.lo hash-string.lo loadmsgcat.lo localealias.lo textdomain.lo l10nflist.lo explodename.lo dcigettext.lo dcngettext.lo dngettext.lo ngettext.lo plural.lo plural-exp.lo langprefs.lo log.lo printf.lo setlocale.lo version.lo osdep.lo intl-compat.lo gnulib-lib/relocatable.lo gnulib-lib/vasnprintf.lo gnulib-lib/printf-args.lo gnulib-lib/printf-parse.lo gnulib-lib/libgnu.la libintl.res.lo
libtool: link: rm -fr  .libs/libintl.dll.a .libs/libintl.exp
libtool: link: /usr/bin/x86_64-w64-mingw32-nm -B  .libs/bindtextdom.o .libs/dcgettext.o .libs/dgettext.o .libs/gettext.o .libs/finddomain.o .libs/hash-string.o .libs/loadmsgcat.o .libs/localealias.o .libs/textdomain.o .libs/l10nflist.o .libs/explodename.o .libs/dcigettext.o .libs/dcngettext.o .libs/dngettext.o .libs/ngettext.o .libs/plural.o .libs/plural-exp.o .libs/langprefs.o .libs/log.o .libs/printf.o .libs/setlocale.o .libs/version.o .libs/osdep.o .libs/intl-compat.o .libs/libintl.res.o   gnulib-lib/.libs/libgnu.a | /usr/bin/sed -n -e 's/^.*[     ]\([ABCDGIRSTW][ABCDGIRSTW]*\)[         ][      ]*\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2 \2/p' | /usr/bin/sed '/ __gnu_lto/d' | /usr/bin/sed -e '/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //' | sort | uniq > .libs/libintl.exp
libtool: link: /usr/bin/grep -E -e "^([^_]|_[^l]|_l[^i]|_li[^b]|_lib[^i]|_libi[^n]|_libin[^t]|_libint[^l]|_libintl[^_]).*" ".libs/libintl.exp" > ".libs/libintl.expT"
libtool: link: mv -f ".libs/libintl.expT" ".libs/libintl.exp"
libtool: link: if test DEF = "`/usr/bin/sed -n -e 's/^[  ]*//' -e '/^\(;.*\)*$/d' -e 's/^\(EXPORTS\|LIBRARY\)\([         ].*\)*$/DEF/p' -e q .libs/libintl.exp`" ; then cp .libs/libintl.exp .libs/libintl-8.dll.def; else echo EXPORTS > .libs/libintl-8.dll.def; cat .libs/libintl.exp >> .libs/libintl-8.dll.def; fi
libtool: link:  x86_64-w64-mingw32-gcc -shared .libs/libintl-8.dll.def  .libs/bindtextdom.o .libs/dcgettext.o .libs/dgettext.o .libs/gettext.o .libs/finddomain.o .libs/hash-string.o .libs/loadmsgcat.o .libs/localealias.o .libs/textdomain.o .libs/l10nflist.o .libs/explodename.o .libs/dcigettext.o .libs/dcngettext.o .libs/dngettext.o .libs/ngettext.o .libs/plural.o .libs/plural-exp.o .libs/langprefs.o .libs/log.o .libs/printf.o .libs/setlocale.o .libs/version.o .libs/osdep.o .libs/intl-compat.o .libs/libintl.res.o  -Wl,--whole-archive gnulib-lib/.libs/libgnu.a -Wl,--no-whole-archive  -ladvapi32 -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib  -g -O2 -Wl,--export-all-symbols   -o .libs/libintl-8.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libintl.dll.a
/usr/lib/gcc/x86_64-w64-mingw32/11/../../../../x86_64-w64-mingw32/bin/ld: .libs/localealias.o: in function `read_alias_file':
/cygdrive/c/src/gettext_git/gettext-runtime/intl/./localealias.c:241: undefined reference to `_libintl_relocate2'
...

AAAAAAAAAAAAAAAAAARRRHRHRHRHRHHHRHGG!!!!!!1!

So -- how can I hack in my changes in this project, so that build succeeds at least at this failing step? (for reference, here is the Makefile I've got generated in this directory)


问:
Speech recognition- microphone not working with exe files made using pyinstaller
```<code>import pyttsx3
import speech_recognition as sr
from tkinter import *
from PIL import Image,ImageTk
from customtkinter import *

def micro():
        global statement
        r=sr.Recognizer()
        with sr.Microphone() as source:
            r.adjust_for_ambient_noise(source=source)
            audio=r.listen(source)
            r.energy_threshold=200
            r.pause_threshold=0.5
            try:
                statement=r.recognize_google(audio)
            except Exception as e:
                statement=" "
                engine.say("Pardon me ,please say that again")
                engine.runAndWait()

def text_fill():
    micro()
    text_area.insert("end"," "+ statement)

def main():
    global root,label,frame1,engine,image1
    root=CTk()
    root.geometry("700x600")
    root.resizable(0,0)
    root.title("Notepad")
    frame1=CTkFrame(root,width=150,height=580)
    frame1.pack_propagate(False)
    frame1.place(x=10,y=10)
    set_appearance_mode("dark")
    set_default_color_theme("green")
    engine=pyttsx3.init()
    label=CTkLabel(root,text="File",width=520,height=40,font=("Algerian",30))
    label.place(x=170,y=10)
    global S
    global text_area
    text_area=CTkTextbox(root,height=580,width=520,)
    text_area.place(x=170,y=60)
    image1=CTkImage(Image.open("microphone.png"),size=(26,26))
    micro_button=CTkButton(root,image=image1,width=10,height=10,text="",command=text_fill)
    micro_button.place(x=650,y=15)

    root.update()
    root.mainloop()

if __name__=="__main__":
        main()

</code>```

I have converted this program into a .exe file using pyinstaller.
Whenever I run the normal program, i got to see a microphone in the taskbar and the program is running smoothly but when I run its exe file no microphone is shown in the taskbar and thus I am unable to provide input using voice.

Body:
import pyttsx3
import speech_recognition as sr
from tkinter import *
from PIL import Image,ImageTk
from customtkinter import *

def micro():
        global statement
        r=sr.Recognizer()
        with sr.Microphone() as source:
            r.adjust_for_ambient_noise(source=source)
            audio=r.listen(source)
            r.energy_threshold=200
            r.pause_threshold=0.5
            try:
                statement=r.recognize_google(audio)
            except Exception as e:
                statement=" "
                engine.say("Pardon me ,please say that again")
                engine.runAndWait()

def text_fill():
    micro()
    text_area.insert("end"," "+ statement)

def main():
    global root,label,frame1,engine,image1
    root=CTk()
    root.geometry("700x600")
    root.resizable(0,0)
    root.title("Notepad")
    frame1=CTkFrame(root,width=150,height=580)
    frame1.pack_propagate(False)
    frame1.place(x=10,y=10)
    set_appearance_mode("dark")
    set_default_color_theme("green")
    engine=pyttsx3.init()
    label=CTkLabel(root,text="File",width=520,height=40,font=("Algerian",30))
    label.place(x=170,y=10)
    global S
    global text_area
    text_area=CTkTextbox(root,height=580,width=520,)
    text_area.place(x=170,y=60)
    image1=CTkImage(Image.open("microphone.png"),size=(26,26))
    micro_button=CTkButton(root,image=image1,width=10,height=10,text="",command=text_fill)
    micro_button.place(x=650,y=15)

    root.update()
    root.mainloop()

if __name__=="__main__":
        main()

I have converted this program into a .exe file using pyinstaller.
Whenever I run the normal program, i got to see a microphone in the taskbar and the program is running smoothly but when I run its exe file no microphone is shown in the taskbar and thus I am unable to provide input using voice.


问:
line with * at the beginning and end, and an appropriate number of spaces in between in Python
I am new to Python. When I printed a line with * at the beginning and end, and an appropriate number of spaces in between, I got it correct but when I tried a different way shorter than the first way, I got * indented by 2 spaces with no reason.

```<code>  print("*", end = ""), print(" " * (num), end = ""), print("*") // it works
  *                              *             //1st way sample output

  print("*", " " * (num) ,"*")                // 2nd way doesn't work
  *                                 *         // 2nd way sample output
                                             // the last * is indented by 2 spaces
</code>```

Any clarification, Thanks

Body:
I am new to Python. When I printed a line with * at the beginning and end, and an appropriate number of spaces in between, I got it correct but when I tried a different way shorter than the first way, I got * indented by 2 spaces with no reason.

  print("*", end = ""), print(" " * (num), end = ""), print("*") // it works
  *                              *             //1st way sample output

  print("*", " " * (num) ,"*")                // 2nd way doesn't work
  *                                 *         // 2nd way sample output
                                             // the last * is indented by 2 spaces

Any clarification, Thanks


问:
detectron2 Import Error while debugging in PyCharm
My IDE is Pycharm Community Edition.

I have followed the official document to install detectron2 from source code. When I click the "run" button in Pycharm, it just works fine. However, when I tried to debug my code by clicking the debug button, Pycharm just threw the Exception:

```<code>Import Error("cannot import name '_C' from 'detectron2'(/path to my detectron2 source code )")
</code>```

Whats wrong with my Pycharm? Why does it work fine when I "run" it but fail when I debug it?

Body:
My IDE is Pycharm Community Edition.

I have followed the official document to install detectron2 from source code. When I click the "run" button in Pycharm, it just works fine. However, when I tried to debug my code by clicking the debug button, Pycharm just threw the Exception:

Import Error("cannot import name '_C' from 'detectron2'(/path to my detectron2 source code )")

Whats wrong with my Pycharm? Why does it work fine when I "run" it but fail when I debug it?


问:
C# Masked textbox with date format skips first character
I have a problem in a winform app.
I have several masked textbox which use the short date mask (//____), the problem is that if I select all the text (either with Ctrl + a or from code) and I write a new date is like that the first character goes at an 11th position (the mask disappear and i see only the character I wrote) and if I press backspace the text becomes something like this _1/01/1979 and I have to select all again and press backspace or delete everything.

I handled in this way

```<code>private void maskedTxt_KeyPress(object sender, KeyPressEventArgs e)
        {
            MaskedTextBox msk = sender as MaskedTextBox;
            if (msk != null)
            {
                if (!string.IsNullOrEmpty(msk.Text.Replace("/", string.Empty).Replace(":", string.Empty).Trim()) && _focused)
                {
                    _focused = false;
                    SendKeys.SendWait("{BACKSPACE}");
                }
            }
        }
</code>```

_focused is a Boolean variable that I set to true if a validation error happens at the leave event of the masked textbox (invalid date, the date is too big or too small etc...)
so that when someone enters the textbox the text can be written correctly

Is there a better way to handle this "error" or this is good? I tried it and it worked but a lot of people will have to use this application and probably there will be some errors along the way.
Thanks

Body:
I have a problem in a winform app.
I have several masked textbox which use the short date mask (//____), the problem is that if I select all the text (either with Ctrl + a or from code) and I write a new date is like that the first character goes at an 11th position (the mask disappear and i see only the character I wrote) and if I press backspace the text becomes something like this _1/01/1979 and I have to select all again and press backspace or delete everything.

I handled in this way

private void maskedTxt_KeyPress(object sender, KeyPressEventArgs e)
        {
            MaskedTextBox msk = sender as MaskedTextBox;
            if (msk != null)
            {
                if (!string.IsNullOrEmpty(msk.Text.Replace("/", string.Empty).Replace(":", string.Empty).Trim()) && _focused)
                {
                    _focused = false;
                    SendKeys.SendWait("{BACKSPACE}");
                }
            }
        }

_focused is a Boolean variable that I set to true if a validation error happens at the leave event of the masked textbox (invalid date, the date is too big or too small etc...)
so that when someone enters the textbox the text can be written correctly

Is there a better way to handle this "error" or this is good? I tried it and it worked but a lot of people will have to use this application and probably there will be some errors along the way.
Thanks


问:
I have two dataframes that I want to merge to matchh first and last names in R
I have  df1 with:

Name
First name
Education

Smith
John
Studiess in Education

Ricco
Toma
Busienss

Mabel
Elvira
Business

and df2 with:

Name
First name

Smith
John

Mabel
Elvira

And want to achieve df3

Name
First name
Education

Smith
John
Studiess in Education

Mabel
Elvira
Business

That is only select the name and first names that are in df2 in df1 while keeping education.
Thanks!


问:
Asking google form to populate multiple file upload questions into 1 folder for each submission
I have this script for my google form that has multiple file upload questions. Generally google forms will automatically create folders for each question in our drive.

My aim is to transfer all files into 1 folder (separated by response), rather than having to look into multiple folders for 1 response. I have done this script where the files will create a folder based on 2nd question (as title) and be in a designated folder (added folder id). However, there are some times where the  google form response does not perform the trigger (failed).

Hope someone can help with the script. Because there is no indication of the error and i will need to manually look occassionally.

This is my script

```<code>const PARENT_FOLDER_ID = "1Za2tSQzjjmT4spA7azrI9hVerRLrPcz2";

const initialize = () => {
  const form = FormApp.getActiveForm();
  ScriptApp.newTrigger("onFormSubmit").forForm(form).onFormSubmit().create();
};

const onFormSubmit = ({ response } = {}) => {
  try {
    // Get some useful data to create the subfolder name
    const firstItemAnswer = response.getItemResponses()[0].getResponse() // text in first answer
    const seconditemAnswer = response.getItemResponses () [1].getResponse() // text in 2nd
    const user = response.getRespondentEmail()  // email (Collect email addresses must be enabled)
    const time = response.getTimestamp()  // when the response was submited
    const subfolderName = seconditemAnswer

    // Get a list of all files uploaded with the response
    const files = response
      .getItemResponses()
      // We are only interested in File Upload type of questions
      .filter(
        (itemResponse) =>
          itemResponse.getItem().getType().toString() === "FILE_UPLOAD"
      )
      .map((itemResponse) => itemResponse.getResponse())
      // The response includes the file ids in an array that we can flatten
      .reduce((a, b) => [...a, ...b], []);

    if (files.length > 0) {
      // Each form response has a unique Id
      const parentFolder = DriveApp.getFolderById(PARENT_FOLDER_ID);
      const subfolder = parentFolder.createFolder(subfolderName);
      files.forEach((fileId) => {
        // Move each file into the custom folder
        DriveApp.getFileById(fileId).moveTo(subfolder);
      });
    }
  } catch (f) {
    Logger.log(f);
  }
};
</code>```

Body:
I have this script for my google form that has multiple file upload questions. Generally google forms will automatically create folders for each question in our drive.

My aim is to transfer all files into 1 folder (separated by response), rather than having to look into multiple folders for 1 response. I have done this script where the files will create a folder based on 2nd question (as title) and be in a designated folder (added folder id). However, there are some times where the  google form response does not perform the trigger (failed).

Hope someone can help with the script. Because there is no indication of the error and i will need to manually look occassionally.

This is my script

const PARENT_FOLDER_ID = "1Za2tSQzjjmT4spA7azrI9hVerRLrPcz2";

const initialize = () => {
  const form = FormApp.getActiveForm();
  ScriptApp.newTrigger("onFormSubmit").forForm(form).onFormSubmit().create();
};

const onFormSubmit = ({ response } = {}) => {
  try {
    // Get some useful data to create the subfolder name
    const firstItemAnswer = response.getItemResponses()[0].getResponse() // text in first answer
    const seconditemAnswer = response.getItemResponses () [1].getResponse() // text in 2nd
    const user = response.getRespondentEmail()  // email (Collect email addresses must be enabled)
    const time = response.getTimestamp()  // when the response was submited
    const subfolderName = seconditemAnswer

    // Get a list of all files uploaded with the response
    const files = response
      .getItemResponses()
      // We are only interested in File Upload type of questions
      .filter(
        (itemResponse) =>
          itemResponse.getItem().getType().toString() === "FILE_UPLOAD"
      )
      .map((itemResponse) => itemResponse.getResponse())
      // The response includes the file ids in an array that we can flatten
      .reduce((a, b) => [...a, ...b], []);

    if (files.length > 0) {
      // Each form response has a unique Id
      const parentFolder = DriveApp.getFolderById(PARENT_FOLDER_ID);
      const subfolder = parentFolder.createFolder(subfolderName);
      files.forEach((fileId) => {
        // Move each file into the custom folder
        DriveApp.getFileById(fileId).moveTo(subfolder);
      });
    }
  } catch (f) {
    Logger.log(f);
  }
};


问:
renderCustomNodeElement prop not functioning
I am using the react-d3-tree to render a tree chart. I want to use create a custom node by passing a function to the renderCustomNodeElement prop, but somehow it seems this prop is not accepting the value passed.

Here is the code:

```<code>import React, { useState, useEffect } from 'react';
import Tree from "react-d3-tree";
import { useCenteredTree } from "./helpers";
import "./Tree.css";
import Cookies from 'js-cookie';
import { load_tree } from '../actions/tree';
import { connect } from 'react-redux';

const mapStateToProps = state => ({
  tree: state.tree
});

const renderRectSvgNode = ({ nodeDatum, toggleNode }) => (
  <g>
    <rect width="20" height="20" x="-10" onClick={toggleNode} />
    <text fill="black" strokeWidth="1" x="20">
      {nodeDatum.name}
    </text>
    {nodeDatum.attributes?.department && (
      <text fill="black" x="20" dy="20" strokeWidth="1">
        Department: {nodeDatum.attributes?.department}
      </text>
    )}
  </g>
);

export function TreeGraph({tree}) {

  const containerStyles = {
    width: "100vw",
    height: "100vh"
  };

  const [translate, containerRef] = useCenteredTree();
  const nodeSize = { x: 100, y: 100 };
  const foreignObjectProps = { width: nodeSize.x, height: nodeSize.y, x: -100 };

  const makeTree = (familyData, CustomNodeElementFunction, nodeSize) => {
    console.log(CustomNodeElementFunction);
    return (
    <Tree
      data={familyData}
      rootNodeClassName="node__root"
      branchNodeClassName="node__branch"
      leafNodeClassName="node__leaf"
      translate={translate}
      nodeSize={nodeSize}
      renderCustomNodeElement={CustomNodeElementFunction}
      pathFunc="step"
      initialDepth="1"
      orientation="vertical"
    />
  );}

  return (

    <div dir="ltr" style={containerStyles} ref={containerRef}>
      { typeof  tree.payload !== 'undefined' && tree.payload.length > 0
      ? makeTree(tree.payload, renderRectSvgNode, nodeSize)
      : makeTree({}, renderRectSvgNode, nodeSize) }
    </div>
  );
}

export default connect(mapStateToProps)(TreeGraph);

</code>```

Can someone see what is missing?

Body:
I am using the react-d3-tree to render a tree chart. I want to use create a custom node by passing a function to the renderCustomNodeElement prop, but somehow it seems this prop is not accepting the value passed.

Here is the code:

import React, { useState, useEffect } from 'react';
import Tree from "react-d3-tree";
import { useCenteredTree } from "./helpers";
import "./Tree.css";
import Cookies from 'js-cookie';
import { load_tree } from '../actions/tree';
import { connect } from 'react-redux';

const mapStateToProps = state => ({
  tree: state.tree
});

const renderRectSvgNode = ({ nodeDatum, toggleNode }) => (
  <g>
    <rect width="20" height="20" x="-10" onClick={toggleNode} />
    <text fill="black" strokeWidth="1" x="20">
      {nodeDatum.name}
    </text>
    {nodeDatum.attributes?.department && (
      <text fill="black" x="20" dy="20" strokeWidth="1">
        Department: {nodeDatum.attributes?.department}
      </text>
    )}
  </g>
);

export function TreeGraph({tree}) {

  const containerStyles = {
    width: "100vw",
    height: "100vh"
  };

  const [translate, containerRef] = useCenteredTree();
  const nodeSize = { x: 100, y: 100 };
  const foreignObjectProps = { width: nodeSize.x, height: nodeSize.y, x: -100 };

  const makeTree = (familyData, CustomNodeElementFunction, nodeSize) => {
    console.log(CustomNodeElementFunction);
    return (
    <Tree
      data={familyData}
      rootNodeClassName="node__root"
      branchNodeClassName="node__branch"
      leafNodeClassName="node__leaf"
      translate={translate}
      nodeSize={nodeSize}
      renderCustomNodeElement={CustomNodeElementFunction}
      pathFunc="step"
      initialDepth="1"
      orientation="vertical"
    />
  );}

  return (

      { typeof  tree.payload !== 'undefined' && tree.payload.length > 0
      ? makeTree(tree.payload, renderRectSvgNode, nodeSize)
      : makeTree({}, renderRectSvgNode, nodeSize) }

  );
}

export default connect(mapStateToProps)(TreeGraph);

Can someone see what is missing?


问:
Full screen on a div element on IOS Not working I want to show some overlay on video tag in fullscreen like youtube
on fullscreen video i want to show some overlay content

the approach i tried is I wrapped video tag in side a div

`

```<code><div ref={v_container}>
<video>

</div>
</code>```

`

and making a div fullscreen is working in android but not in ios

because ios doesn't support fullscreen API on div

any other approach

a different approach to solving this problem

I want youtube like fullscreen , when video is paused show some data regarding video

Body:
on fullscreen video i want to show some overlay content

the approach i tried is I wrapped video tag in side a div

`

<video>

`

and making a div fullscreen is working in android but not in ios

because ios doesn't support fullscreen API on div

any other approach

a different approach to solving this problem

I want youtube like fullscreen , when video is paused show some data regarding video


问:
Installing PHPPresentation Codeigniter
Does someone successfully tried to install and integrate the PHPPresentation library in Codeigniter, tried it several times but got no luck.

Here's my sample source code
`// with Composer
require_once APPPATH.'third_party/vendor/autoload.php';

```<code>    $objPHPPowerPoint = new PhpPresentation();
                       die('x');

    // // Create slide
    $currentSlide = $objPHPPowerPoint->getActiveSlide();

    // Create a shape (drawing)
    $shape = $currentSlide->createDrawingShape();

    $shape->setName('PHPPresentation logo')
          ->setDescription('PHPPresentation logo')
          ->setPath('./resources/phppowerpoint_logo.gif')
          ->setHeight(36)
          ->setOffsetX(10)
          ->setOffsetY(10);

    $shape->getShadow()->setVisible(true)
                       ->setDirection(45)
                       ->setDistance(10);

    // Create a shape (text)
    $shape = $currentSlide->createRichTextShape()
          ->setHeight(300)
          ->setWidth(600)
          ->setOffsetX(170)
          ->setOffsetY(180);
    $shape->getActiveParagraph()->getAlignment()->setHorizontal( Alignment::HORIZONTAL_CENTER );
    $textRun = $shape->createTextRun('Thank you for using PHPPresentation!');
    $textRun->getFont()->setBold(true)
                       ->setSize(60)
                       ->setColor( new Color( 'FFE06B20' ) );

    $oWriterPPTX = IOFactory::createWriter($objPHPPowerPoint, 'PowerPoint2007');
    $oWriterPPTX->save(__DIR__ . "/sample.pptx");
    $oWriterODP = IOFactory::createWriter($objPHPPowerPoint, 'ODPresentation');
    $oWriterODP->save(__DIR__ . "/sample.odp");
</code>```

`

Title: Installing PHPPresentation Codeigniter

Body:
Does someone successfully tried to install and integrate the PHPPresentation library in Codeigniter, tried it several times but got no luck.

Here's my sample source code
`// with Composer
require_once APPPATH.'third_party/vendor/autoload.php';

    $objPHPPowerPoint = new PhpPresentation();
                       die('x');

    // // Create slide
    $currentSlide = $objPHPPowerPoint->getActiveSlide();

    // Create a shape (drawing)
    $shape = $currentSlide->createDrawingShape();

    $shape->setName('PHPPresentation logo')
          ->setDescription('PHPPresentation logo')
          ->setPath('./resources/phppowerpoint_logo.gif')
          ->setHeight(36)
          ->setOffsetX(10)
          ->setOffsetY(10);

    $shape->getShadow()->setVisible(true)
                       ->setDirection(45)
                       ->setDistance(10);

    // Create a shape (text)
    $shape = $currentSlide->createRichTextShape()
          ->setHeight(300)
          ->setWidth(600)
          ->setOffsetX(170)
          ->setOffsetY(180);
    $shape->getActiveParagraph()->getAlignment()->setHorizontal( Alignment::HORIZONTAL_CENTER );
    $textRun = $shape->createTextRun('Thank you for using PHPPresentation!');
    $textRun->getFont()->setBold(true)
                       ->setSize(60)
                       ->setColor( new Color( 'FFE06B20' ) );

    $oWriterPPTX = IOFactory::createWriter($objPHPPowerPoint, 'PowerPoint2007');
    $oWriterPPTX->save(__DIR__ . "/sample.pptx");
    $oWriterODP = IOFactory::createWriter($objPHPPowerPoint, 'ODPresentation');
    $oWriterODP->save(__DIR__ . "/sample.odp");

`


问:
Why/when is numpy.equal() 10x faster when working with x.T.copy() instead of x.T?
Context: I made the following observations when trying to optimize my code for speed. It involves the use of large square matrices with up to 3.6e9 elements (assuming I can speed it up sufficiently ...).

Observations: Consider a square numpy array x. Doing x == x.T takes significantly longer than x == x, x == x.T.copy(), or even x.T == x.T. If x has 1e8 elements, x == x.T is 10x times slower than all other variants (on my system), including doing x.T.copy().

Question: I suppose that the speed loss is related to the fact that x.T returns a view of x ? I am however surprised at the amplitude of the loss. I was even more surprised to realize that working with two transposed arrays, or with copies of the transposed array appears to have very little overhead.

I am now left wondering if I should start systematically copying my transposed numpy arrays (i.e. use x.T.copy() instead of x.T) to gain significant speed in my code ?

Is this expected behavior from numpy, or could there be something off with my setup (incl. the underlying BLAS/LAPACK) ?

MWE:

```<code>from datetime import datetime
import numpy as np

def time_loop(a, b, niter=10):

    time = 0
    for _ in range(niter):
        start = datetime.now()
        _ = (a == b)
        time += (datetime.now()-start).total_seconds()

    return time/niter

very_start = datetime.now()

for size in [100, 1000, 10000, 15000, 20000]:
    print(f'\nsize: {size}')

    # Create the array once to not influence the timings
    x = np.random.rand(size, size)
    # Create the transpose too already
    x_t = x.T
    x_t_c = x.T.copy()

    # Case 1: straight vs straight
    print(f' x == x: {time_loop(x, x):.6f}s')

    # Case 2: straight vs transposed
    print(f' x == x.T: {time_loop(x, x_t):.6f}s')

    # Case 3: straight vs transposed.copy()
    print(f' x == x.T.copy(): {time_loop(x, x_t_c):.6f}s')

    # Case 4: transposed vs transposed
    print(f' x.T == x.T: {time_loop(x_t, x_t):.6f}s')

print(f'\nTotal runtime: {(datetime.now()-very_start).total_seconds():.1f}s')
</code>```

returns

```<code>size: 100
 x == x: 0.000005s
 x == x.T: 0.000010s
 x == x.T.copy(): 0.000004s
 x.T == x.T: 0.000004s

size: 1000
 x == x: 0.000412s
 x == x.T: 0.001698s
 x == x.T.copy(): 0.000887s
 x.T == x.T: 0.000396s

size: 10000
 x == x: 0.070157s
 x == x.T: 1.024655s
 x == x.T.copy(): 0.099336s
 x.T == x.T: 0.067587s

size: 15000
 x == x: 0.151993s
 x == x.T: 2.561973s
 x == x.T.copy(): 0.223449s
 x.T == x.T: 0.152339s

size: 20000
 x == x: 0.280847s
 x == x.T: 6.938656s
 x == x.T.copy(): 0.396516s
 x.T == x.T: 0.275735s

Total runtime: 141.5s
</code>```

on my system:
OS X, Python 3.10.6 via miniconda/conda-forge, numpy 1.23.4

```<code>
In [111]: np.show_config()
blas_info:
    libraries = ['cblas', 'blas', 'cblas', 'blas']
    library_dirs = ['/Some/secret/path']
    include_dirs = ['/Some/secret/path']
    language = c
    define_macros = [('HAVE_CBLAS', None)]
blas_opt_info:
    define_macros = [('NO_ATLAS_INFO', 1), ('HAVE_CBLAS', None)]
    libraries = ['cblas', 'blas', 'cblas', 'blas']
    library_dirs = ['/Some/secret/path']
    include_dirs = ['/Some/secret/path']
    language = c
lapack_info:
    libraries = ['lapack', 'blas', 'lapack', 'blas']
    library_dirs = ['/Some/secret/path']
    language = f77
lapack_opt_info:
    libraries = ['lapack', 'blas', 'lapack', 'blas', 'cblas', 'blas', 'cblas', 'blas']
    library_dirs = ['/Some/secret/path']
    language = c
    define_macros = [('NO_ATLAS_INFO', 1), ('HAVE_CBLAS', None)]
    include_dirs = ['/Some/secret/path']
Supported SIMD extensions in this NumPy install:
    baseline = SSE,SSE2,SSE3
    found = SSSE3,SSE41,POPCNT,SSE42,AVX,F16C,FMA3,AVX2
    not found = AVX512F,AVX512CD,AVX512_KNL,AVX512_SKX,AVX512_CLX,AVX512_CNL,AVX512_ICL
</code>```

Body:
Context: I made the following observations when trying to optimize my code for speed. It involves the use of large square matrices with up to 3.6e9 elements (assuming I can speed it up sufficiently ...).

Observations: Consider a square numpy array x. Doing x == x.T takes significantly longer than x == x, x == x.T.copy(), or even x.T == x.T. If x has 1e8 elements, x == x.T is 10x times slower than all other variants (on my system), including doing x.T.copy().

Question: I suppose that the speed loss is related to the fact that x.T returns a view of x ? I am however surprised at the amplitude of the loss. I was even more surprised to realize that working with two transposed arrays, or with copies of the transposed array appears to have very little overhead.

I am now left wondering if I should start systematically copying my transposed numpy arrays (i.e. use x.T.copy() instead of x.T) to gain significant speed in my code ?

Is this expected behavior from numpy, or could there be something off with my setup (incl. the underlying BLAS/LAPACK) ?

MWE:

from datetime import datetime
import numpy as np

def time_loop(a, b, niter=10):

    time = 0
    for _ in range(niter):
        start = datetime.now()
        _ = (a == b)
        time += (datetime.now()-start).total_seconds()

    return time/niter

very_start = datetime.now()

for size in [100, 1000, 10000, 15000, 20000]:
    print(f'\nsize: {size}')

    # Create the array once to not influence the timings
    x = np.random.rand(size, size)
    # Create the transpose too already
    x_t = x.T
    x_t_c = x.T.copy()

    # Case 1: straight vs straight
    print(f' x == x: {time_loop(x, x):.6f}s')

    # Case 2: straight vs transposed
    print(f' x == x.T: {time_loop(x, x_t):.6f}s')

    # Case 3: straight vs transposed.copy()
    print(f' x == x.T.copy(): {time_loop(x, x_t_c):.6f}s')

    # Case 4: transposed vs transposed
    print(f' x.T == x.T: {time_loop(x_t, x_t):.6f}s')

print(f'\nTotal runtime: {(datetime.now()-very_start).total_seconds():.1f}s')

returns

size: 100
 x == x: 0.000005s
 x == x.T: 0.000010s
 x == x.T.copy(): 0.000004s
 x.T == x.T: 0.000004s

size: 1000
 x == x: 0.000412s
 x == x.T: 0.001698s
 x == x.T.copy(): 0.000887s
 x.T == x.T: 0.000396s

size: 10000
 x == x: 0.070157s
 x == x.T: 1.024655s
 x == x.T.copy(): 0.099336s
 x.T == x.T: 0.067587s

size: 15000
 x == x: 0.151993s
 x == x.T: 2.561973s
 x == x.T.copy(): 0.223449s
 x.T == x.T: 0.152339s

size: 20000
 x == x: 0.280847s
 x == x.T: 6.938656s
 x == x.T.copy(): 0.396516s
 x.T == x.T: 0.275735s

Total runtime: 141.5s

on my system:
OS X, Python 3.10.6 via miniconda/conda-forge, numpy 1.23.4

In [111]: np.show_config()
blas_info:
    libraries = ['cblas', 'blas', 'cblas', 'blas']
    library_dirs = ['/Some/secret/path']
    include_dirs = ['/Some/secret/path']
    language = c
    define_macros = [('HAVE_CBLAS', None)]
blas_opt_info:
    define_macros = [('NO_ATLAS_INFO', 1), ('HAVE_CBLAS', None)]
    libraries = ['cblas', 'blas', 'cblas', 'blas']
    library_dirs = ['/Some/secret/path']
    include_dirs = ['/Some/secret/path']
    language = c
lapack_info:
    libraries = ['lapack', 'blas', 'lapack', 'blas']
    library_dirs = ['/Some/secret/path']
    language = f77
lapack_opt_info:
    libraries = ['lapack', 'blas', 'lapack', 'blas', 'cblas', 'blas', 'cblas', 'blas']
    library_dirs = ['/Some/secret/path']
    language = c
    define_macros = [('NO_ATLAS_INFO', 1), ('HAVE_CBLAS', None)]
    include_dirs = ['/Some/secret/path']
Supported SIMD extensions in this NumPy install:
    baseline = SSE,SSE2,SSE3
    found = SSSE3,SSE41,POPCNT,SSE42,AVX,F16C,FMA3,AVX2
    not found = AVX512F,AVX512CD,AVX512_KNL,AVX512_SKX,AVX512_CLX,AVX512_CNL,AVX512_ICL


问:
PHP: upload a file using POST method without a form (command line)
I am trying to upload a file directly to the server using "curl" instead of using HTML submit form. I have the below php code on the server:

upload.php

```<code><?php
$uldir = '/tmp/repos/';
$ulfile = $uldir . basename($_FILES['userfile']['name']);

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $ulfile)) {
    echo "Uploaded successfully.\n";
} else {
    echo "Could not upload file!\n";
}

?>
</code>```

I could make it work if I use HTML form to submit and call the php, but then I want to do something similar to CGI where I can directly post the file. I use this curl command, but I get internal error from server:

```<code>curl -XPOST -T /tmp/image.png https://web-server-host/upload.php
</code>```

This is usually possible with CGI, is it with PHP?

Note: this is not intended to be production config, its a test server, w.r.t security.

Body:
I am trying to upload a file directly to the server using "curl" instead of using HTML submit form. I have the below php code on the server:

upload.php

<?php
$uldir = '/tmp/repos/';
$ulfile = $uldir . basename($_FILES['userfile']['name']);

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $ulfile)) {
    echo "Uploaded successfully.\n";
} else {
    echo "Could not upload file!\n";
}

?>

I could make it work if I use HTML form to submit and call the php, but then I want to do something similar to CGI where I can directly post the file. I use this curl command, but I get internal error from server:

curl -XPOST -T /tmp/image.png https://web-server-host/upload.php

This is usually possible with CGI, is it with PHP?

Note: this is not intended to be production config, its a test server, w.r.t security.


问:
React Vite + React Router Dom - Scroll bar missing after clicking on NavLink
I need some help... I'm building a multi-page B&B app using React (Vite) and React Router Dom. I'm also using React Query, React Scroll Parallax, Material UI and Redux Toolkit.

Here's my problem:
If I click on most of the NavLink components in my navbar, the url changes and the page routes correctly, BUT, the scroll bar is missing and I can't scroll the page. However if I manually refresh the page in the browser, the scroll bar is back again and everything works as expected. Also, this doesn't happen on all of my NavLinks, only some of them. For instance, the Login and Register NavLinks render with the scrollbar, as well as my About page inside my Footer component. I have checked to see if there are any differences in the structuring of the Routes or the NavLink components, but I couldn't see any differences.

I have tried automatically refreshing the page once with useEffect, but I can't get it to refresh only once, it keeps refreshing in a loop, so I removed it...

ANY HELP WOULD BE HIGHLY APPRECIATED...

Here is my App.jsx:

```<code>function App() {
  const { pathname } = useLocation();

  useEffect(() => {
    window.scrollTo(0, 0);
  }, [pathname]);

  return (
    <div className="App">
      <Navbar />

      <div id="back-to-top-anchor" style={{ minHeight: "0" }}></div>

      <ParallaxProvider>
        <Routes>
          <Route path="/" element={<Home />} />
          <Route path="about" element={<About />} />
          <Route
            path="all-listings"
            element={<AllListings initialState={initialState} />}
          />
          <Route
            path="listing/:listingId"
            element={<Listing initialState={initialState} />}
          />
          <Route path="how-it-works" element={<HowItWorks />} />
          <Route path="contact-us" element={<ContactUs />} />
          <Route path="login" element={<Login />} />
          <Route path="register" element={<Register />} />
          <Route path="*" element={<ErrorPage />} />

          <Route path="my-listings" element={<MyListings />} />
        </Routes>
      </ParallaxProvider>

      <ShapeDivider color="#ffffff">
        <Footer />
      </ShapeDivider>
    </div>
  );
}
</code>```

And here is my menu inside NavBar.jsx:

```<code>  const menu = (
    <>
      <div
        onClick={() => {
          setMobileOpen(true);
        }}
        className={classes.navbarSmallMenu}
      >
        <NavLink
          className={({ isActive }) =>
            isActive ? classes.activeNavbarStyle : undefined
          }
          to="/"
        >
          Home
        </NavLink>
        <NavLink
          className={({ isActive }) =>
            isActive ? classes.activeNavbarStyle : undefined
          }
          to="all-listings"
        >
          All Listings
        </NavLink>
        <NavLink
          className={({ isActive }) =>
            isActive ? classes.activeNavbarStyle : undefined
          }
          to="how-it-works"
        >
          How It Works
        </NavLink>
        <NavLink
          className={({ isActive }) =>
            isActive ? classes.activeNavbarStyle : undefined
          }
          to="contact-us"
        >
          Contact Us
        </NavLink>
      </div>

      <div className={classes.navbarSmallMenu}>
        {isUserLoggedIn ? (
          <>
            <IconButton
              id="profile-avatar"
              onClick={handleOpenUserMenu}
              sx={{ p: 0 }}
            >
              <Avatar alt="User Profile" />
            </IconButton>
            <Menu
              className={classes.profileMenu}
              id="menu-appbar"
              anchorEl={anchorUser}
              anchorOrigin={{
                vertical: "top",
                horizontal: "right",
              }}
              keepMounted
              transformOrigin={{
                vertical: "top",
                horizontal: "right",
              }}
              open={Boolean(anchorUser)}
              onClose={handleCloseUserMenu}
            >
              <NavLink
                className={({ isActive }) =>
                  isActive ? classes.activeNavbarStyle : undefined
                }
                to="/"
              >
                Show Profile
              </NavLink>
              <ul>
                <li>
                  <NavLink
                    className={({ isActive }) =>
                      isActive ? classes.activeNavbarStyle : undefined
                    }
                    to="my-listings"
                  >
                    My Listings
                  </NavLink>
                </li>
                <li>Pages</li>
                <li>Goes</li>
                <li>Here</li>
                <li
                  className={classes.logOutButton}
                  onClick={() => {
                    localStorage.clear();
                    navigate(0);
                  }}
                >
                  Log Out
                </li>
              </ul>
            </Menu>
          </>
        ) : (
          <>
            <NavLink
              className={({ isActive }) =>
                isActive ? classes.activeNavbarStyle : undefined
              }
              to="login"
            >
              Login
            </NavLink>
            <NavLink
              className={({ isActive }) =>
                isActive ? classes.activeNavbarStyle : undefined
              }
              to="register"
            >
              Register
            </NavLink>
          </>
        )}
      </div>
    </>
  );```
```

Body:
I need some help... I'm building a multi-page B&B app using React (Vite) and React Router Dom. I'm also using React Query, React Scroll Parallax, Material UI and Redux Toolkit.

Here's my problem:
If I click on most of the NavLink components in my navbar, the url changes and the page routes correctly, BUT, the scroll bar is missing and I can't scroll the page. However if I manually refresh the page in the browser, the scroll bar is back again and everything works as expected. Also, this doesn't happen on all of my NavLinks, only some of them. For instance, the Login and Register NavLinks render with the scrollbar, as well as my About page inside my Footer component. I have checked to see if there are any differences in the structuring of the Routes or the NavLink components, but I couldn't see any differences.

I have tried automatically refreshing the page once with useEffect, but I can't get it to refresh only once, it keeps refreshing in a loop, so I removed it...

ANY HELP WOULD BE HIGHLY APPRECIATED...

Here is my App.jsx:

function App() {
  const { pathname } = useLocation();

  useEffect(() => {
    window.scrollTo(0, 0);
  }, [pathname]);

  return (

      <Navbar />

      <ParallaxProvider>
        <Routes>
          <Route path="/" element={<Home />} />
          <Route path="about" element={<About />} />
          <Route
            path="all-listings"
            element={<AllListings initialState={initialState} />}
          />
          <Route
            path="listing/:listingId"
            element={<Listing initialState={initialState} />}
          />
          <Route path="how-it-works" element={<HowItWorks />} />
          <Route path="contact-us" element={<ContactUs />} />
          <Route path="login" element={<Login />} />
          <Route path="register" element={<Register />} />
          <Route path="*" element={<ErrorPage />} />

          <Route path="my-listings" element={<MyListings />} />
        </Routes>
      </ParallaxProvider>

      <ShapeDivider color="#ffffff">

      </ShapeDivider>

  );
}

And here is my menu inside NavBar.jsx:

  const menu = (
    <>

 {
          setMobileOpen(true);
        }}
        className={classes.navbarSmallMenu}
      >
        <NavLink
          className={({ isActive }) =>
            isActive ? classes.activeNavbarStyle : undefined
          }
          to="/"
        >
          Home
        </NavLink>
        <NavLink
          className={({ isActive }) =>
            isActive ? classes.activeNavbarStyle : undefined
          }
          to="all-listings"
        >
          All Listings
        </NavLink>
        <NavLink
          className={({ isActive }) =>
            isActive ? classes.activeNavbarStyle : undefined
          }
          to="how-it-works"
        >
          How It Works
        </NavLink>
        <NavLink
          className={({ isActive }) =>
            isActive ? classes.activeNavbarStyle : undefined
          }
          to="contact-us"
        >
          Contact Us
        </NavLink>

        {isUserLoggedIn ? (
          <>
            <IconButton
              id="profile-avatar"
              onClick={handleOpenUserMenu}
              sx={{ p: 0 }}
            >
              <Avatar alt="User Profile" />
            </IconButton>
            <Menu
              className={classes.profileMenu}
              id="menu-appbar"
              anchorEl={anchorUser}
              anchorOrigin={{
                vertical: "top",
                horizontal: "right",
              }}
              keepMounted
              transformOrigin={{
                vertical: "top",
                horizontal: "right",
              }}
              open={Boolean(anchorUser)}
              onClose={handleCloseUserMenu}
            >
              <NavLink
                className={({ isActive }) =>
                  isActive ? classes.activeNavbarStyle : undefined
                }
                to="/"
              >
                Show Profile
              </NavLink>

                  <NavLink
                    className={({ isActive }) =>
                      isActive ? classes.activeNavbarStyle : undefined
                    }
                    to="my-listings"
                  >
                    My Listings
                  </NavLink>

Pages

Goes

Here

 {
                    localStorage.clear();
                    navigate(0);
                  }}
                >
                  Log Out

            </Menu>
          </>
        ) : (
          <>
            <NavLink
              className={({ isActive }) =>
                isActive ? classes.activeNavbarStyle : undefined
              }
              to="login"
            >
              Login
            </NavLink>
            <NavLink
              className={({ isActive }) =>
                isActive ? classes.activeNavbarStyle : undefined
              }
              to="register"
            >
              Register
            </NavLink>
          </>
        )}

    </>
  );```


问:
Is it a good practice to make an API call from layout in Nuxt 3?
I make an API call from a page, then store response data in the Pinia store and use it in that page and the Sidebar component, which is available on all pages as it is a part of the layout. The problem is when I navigate to another page, and for example, reload the page, data is not available cause the API call is made on another page, and the Pinia store isn't saved in localStorage or sessionsStorage. And the solution is to make an API call in the layout. But the Nuxt documentation doesn't say anything about API calls in the layout, so I'm not sure if it is a good practice to make API calls inside layouts

API calls from layout works, there aren't any warnings or erros, but I'm not sure if it is good idea to make an API call in layout.


问:
Cannot connect to blob storage in Data factory
So I want to create a Copy Data Tool in Azure Data Factory, where I connect to a Azure Data Explorer (Kusto) and copy large amounts data to blob storage. There are five steps you have to go through to set up the copy data tool and I am stuck on number three "Destination"

Destination Screen

When I test the Connection it works and I created an empty blob storage in my storage account specifically to store my data. When I press the next button I get the error message

TypeError: Cannot set properties of undefined (setting 'sink')

For the life of me I don't know why... I tried a new connection with a different name and I tried giving different optional params, but nothing seems to work.


问:
@TestPropertySource breaks context and other tests fail
In that class I add the @TestPropertySource:

```<code>@TestConfig
@TestInstance(PER_CLASS)
@TestPropertySource(properties = {"name=BigSam"})
class Test5 {
    //...tests
}
</code>```

I have 5 integration tests. The common configuration for tests:

```<code>@Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@SpringBootTest(classes = MainStart.class)
@ActiveProfiles("test")
public @interface TestConfig {}
</code>```

If I run the Test5 separately it works fine. But, when I run all integration tests together including Test5 class, I see in the logs:

" The following 1 profile is active "test" " - more than one time. ( If I run an integration test without Test5 class, this message appears only one time)

And I the errors:

```<code>java.lang.IllegalStateException: Failed to load ApplicationContext
javax.cache.CacheException: A Cache named "cache-name" already exists.
</code>```

How can the configuration of the test be fixed?
Or how can I change the property source and don't get such errors?

p.s. I use cache from Hibernate, but I don't think that it is a problem.

Body:
In that class I add the @TestPropertySource:

@TestConfig
@TestInstance(PER_CLASS)
@TestPropertySource(properties = {"name=BigSam"})
class Test5 {
    //...tests
}

I have 5 integration tests. The common configuration for tests:

@Target({ElementType.TYPE, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@SpringBootTest(classes = MainStart.class)
@ActiveProfiles("test")
public @interface TestConfig {}

If I run the Test5 separately it works fine. But, when I run all integration tests together including Test5 class, I see in the logs:

" The following 1 profile is active "test" " - more than one time. ( If I run an integration test without Test5 class, this message appears only one time)

And I the errors:

java.lang.IllegalStateException: Failed to load ApplicationContext
javax.cache.CacheException: A Cache named "cache-name" already exists.

How can the configuration of the test be fixed?
Or how can I change the property source and don't get such errors?

p.s. I use cache from Hibernate, but I don't think that it is a problem.


问:
How to keep namespaces in typescript using webpack
I'm using typescript and webpack to bundle some ts-files into one.

In my main ts-file I want to have a public namespace that I can use on a webpage and access it throug the namespace. Like My.cool.np.onLoad();

example:

```<code>export namespace My.Cool.np {

    export function onLoad(){

    }
}
</code>```

this will lead to

```<code>(() => {
    "use strict";
    var o,
    n,
    i;
    (i = {}).My = void 0,
    ((o = (n = i.My || (i.My = {})).Cool || (n.Cool = {})).np || (o.np = {})).onLoad = function () {}
})();
</code>```

it replaced the first part of the namespace "my" with a random char "n".

How can I keep the original namespace?

Best Regards
Tobias

Body:
I'm using typescript and webpack to bundle some ts-files into one.

In my main ts-file I want to have a public namespace that I can use on a webpage and access it throug the namespace. Like My.cool.np.onLoad();

example:

export namespace My.Cool.np {

    export function onLoad(){

    }
}

this will lead to

(() => {
    "use strict";
    var o,
    n,
    i;
    (i = {}).My = void 0,
    ((o = (n = i.My || (i.My = {})).Cool || (n.Cool = {})).np || (o.np = {})).onLoad = function () {}
})();

it replaced the first part of the namespace "my" with a random char "n".

How can I keep the original namespace?

Best Regards
Tobias


问:
mapping of specific record to column in sequelize
I want to associate the models with a given condition like in level only 1 should be visible not country
i tried with adding scope but it's not working
i tried with adding scope but it's not working</p>


问:
WinUI3 : How to get Aeroplane mode toggle event in WinUI3 desktop Application in C++
I'm working of WinUI3 desktop application in C++. I was searching for a way to receive an event when user toggles airplane mode in windows.

I came across a way where where we can check Registry at

```<code>HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\RadioManagement\SystemRadioState
</code>```

with the help of RegNotifyChangeKeyValue

But in this way, we will receive an event handle from RegNotifyChangeKeyValue and have a worker thread continuously waiting for this event handler to be set.

Is there any other way to get the airplane mode toggle event instead of a thread continuously waiting on a register key event to happen?

It would be of great help if you could help me achieve this.

Thank you

Body:
I'm working of WinUI3 desktop application in C++. I was searching for a way to receive an event when user toggles airplane mode in windows.

I came across a way where where we can check Registry at

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\RadioManagement\SystemRadioState

with the help of RegNotifyChangeKeyValue

But in this way, we will receive an event handle from RegNotifyChangeKeyValue and have a worker thread continuously waiting for this event handler to be set.

Is there any other way to get the airplane mode toggle event instead of a thread continuously waiting on a register key event to happen?

It would be of great help if you could help me achieve this.

Thank you


问:
Disallow passing f-strings as argument
I am reporting data from some tests, and each test can have a 'summary' and a 'details' section. The 'summary' field for any particular test should be static, with any additional dynamic information going into the details field, as follows:

```<code>run_test()
if condition:
  report_test_data(summary="condition met", details=f"{component} ended with {state}")
else:
  report_test_data(summary="condition not met", details=f{component} ended with {state}")
</code>```

However, this only applies to these calls to report_test_data, and there is nothing to stop another test from swapping these around, or putting all the data into the 'summary' field:

```<code>run_test()
if condition:
  report_test_data(summary=f"{component} ended with {state} - condition met", details="")
else:
  report_test_data(summary=f"{component} ended with {state} - condition not met", details="")
</code>```

I am analyzing the test data based off the summary, so any particular ending state (e.g. condition = True) should have a static return string. I thought about making a class that manually defines every possible 'summary' string, but that quickly becomes untenable with more tests when a given test can have tens of possible ending states. The best option I can think of is if I could force the value passed into 'summary' to be a normal string. Is there any way to disallow passing f-strings into a particular function?

Note: I use pylint, so if there's an easy way to make it call these out, that would work as well.

Title: Disallow passing f-strings as argument

Body:
I am reporting data from some tests, and each test can have a 'summary' and a 'details' section. The 'summary' field for any particular test should be static, with any additional dynamic information going into the details field, as follows:

run_test()
if condition:
  report_test_data(summary="condition met", details=f"{component} ended with {state}")
else:
  report_test_data(summary="condition not met", details=f{component} ended with {state}")

However, this only applies to these calls to report_test_data, and there is nothing to stop another test from swapping these around, or putting all the data into the 'summary' field:

run_test()
if condition:
  report_test_data(summary=f"{component} ended with {state} - condition met", details="")
else:
  report_test_data(summary=f"{component} ended with {state} - condition not met", details="")

I am analyzing the test data based off the summary, so any particular ending state (e.g. condition = True) should have a static return string. I thought about making a class that manually defines every possible 'summary' string, but that quickly becomes untenable with more tests when a given test can have tens of possible ending states. The best option I can think of is if I could force the value passed into 'summary' to be a normal string. Is there any way to disallow passing f-strings into a particular function?

Note: I use pylint, so if there's an easy way to make it call these out, that would work as well.


问:
SVG gets pixelated on Chromium
Our logo svg is getting pixelated only on Chromium based browsers.
I have seen the other questions and answers with similar issues but that didn't work out.

Any suggestion how to workaround this? I have also filled a bug in Chromium.
Example can be seen here https://cd082856.mirrord-dev.pages.dev/
Attaching screenshots.

Stuff we've tried:

2x/4x svg then resizing.

using css transform

Title: SVG gets pixelated on Chromium